简体   繁体   中英

Mac M1 C++20: Missing std::convertible_to and std::forward_iterator concepts

I'm trying to compile a quite big school project on a Mac M1 and I'm facing some missing concept problem.

The project has not really been thought for arm compilation, but I'm trying to see if it would be possible.

I passed the first step: the configure script runs as expected and generate a Makefile as expected.

The problem appears during compilation of some files of the project: clang seems to be missing some standard library concepts (c++20). I have 2 errors about missing concepts: std::convertible_to and std::forward_iterator.

After some research, I found that the apple version of clang for M1 chips does not fully implements all the c++20 features and I think it is the problem I'm facing.

Is there any other compiler for the AArch64 architecture that implements more features of the modern versions of C++ or should I give up now?

After some research, I found that the apple version of clang for M1 chips does not fully implements all the c++20 features and I think it is the problem I'm facing.

You may want to try Clang from Homebrew(or compile one by yourself). And you can check its implemented features on Clang's offical website.

❯ clang++ --version
Homebrew clang version 13.0.0
Target: arm64-apple-darwin21.1.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin

❯ cat test.cpp
#include <concepts>
#include <iterator>
static_assert(std::convertible_to<char, int>);
static_assert(std::forward_iterator<char*>);

❯ clang++ -std=c++20 -c test.cpp

❯ 

Please remember that C++20 is still quite fresh and it is very big change to the standard (IMO bigger change then C++11). As a result support of some C++20 features is limited and varies between compilers. It will take couple years to have descent support of this standard.

Here is site which lists current status of C++20 features, for different compilers:

Compiler support for C++20 - cppreference.com

C++20 feature Paper(s) GCC libstdc++ Clang libc++ MSVC STL Apple Clang
Concepts library P0898R3 10 13 19.23* 12.0.0* (partial)

So as you can see, Apple clang is a bit behind in supporting concepts library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM