Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] error: no type named 'identity' in namespace 'std' #1845

Closed
MBilderbeek opened this issue Feb 22, 2023 · 2 comments
Closed

[BUG] error: no type named 'identity' in namespace 'std' #1845

MBilderbeek opened this issue Feb 22, 2023 · 2 comments
Labels

Comments

@MBilderbeek
Copy link

Description

This piece of code (which is a minimal part of the openMSX/openMSX project on GitHub, see also here) doesn't compile with the Android NDK C++ compiler, and does compile with clang++.

#include <iostream>
#include <functional>
#include <iterator> // for std::begin(), std::end()

template<typename ForwardRange, typename Compare = std::less<>, typename Proj = std::identity>
[[nodiscard]] bool is_sorted(ForwardRange&& range, Compare comp = {}, Proj proj = {})
{
        return std::is_sorted(std::begin(range), std::end(range),
                [&](const auto& x, const auto& y) {
                        return comp(std::invoke(proj, x), std::invoke(proj, y));
                });
}

int main() {
    std::cout << "Hello World!";
    return 0;
}

This builds fine with clang++:

$ clang++ -std=c++20 test.cc 
$ clang++ --version
Debian clang version 14.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

but not with the NDK clang++:

$ armv7a-linux-androideabi19-clang++ -std=c++20 /tmp/test.cc
/tmp/test.cc:5:86: error: no type named 'identity' in namespace 'std'
template<typename ForwardRange, typename Compare = std::less<>, typename Proj = std::identity>
                                                                                ~~~~~^
1 error generated.
$ armv7a-linux-androideabi19-clang++ --version
Android (8075178, based on r437112b) clang version 14.0.1 (https://android.googlesource.com/toolchain/llvm-project 8671348b81b95fc603505dfc881b45103bee1731)
Target: armv7a-unknown-linux-android19
Thread model: posix
InstalledDir: /usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin

This prevents us from compiling our project on Android, since we are using this C++-20 feature.

Affected versions

r24

Canary version

No response

Host OS

Linux

Host OS version

Debian testing

Affected ABIs

armeabi-v7a

Build system

Other (specify below)

Other build system

none

minSdkVersion

n.a.

Device API level

19

@MBilderbeek MBilderbeek changed the title [BUG] [BUG] error: no type named 'identity' in namespace 'std' Feb 22, 2023
@jfgoog
Copy link
Collaborator

jfgoog commented Feb 22, 2023

This is probably because the version of libc++ in the NDK is somewhat out of date. We are working on fixing this.

@jfgoog
Copy link
Collaborator

jfgoog commented Feb 22, 2023

Duplicate of #1530

@jfgoog jfgoog marked this as a duplicate of #1530 Feb 22, 2023
@jfgoog jfgoog closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants