'std::integral not found in clang13 c++20 error

i try to learn c++20 concepts my compiler version is "Clang 13" i try to compile very simple code block but i got errors following.

"error: no type named 'floating_point' in namespace 'std'" "error: no type named 'integral' in namespace 'std'"

i try gcc 11.2 version also but i got same error.

my build commands is following;

clang++ -Wall -Wextra -std=c++20 -g -Iinclude -Llib src/main.cpp -o bin/main clang++ -Wall -Wextra -std=c++2a -g -Iinclude -Llib src/main.cpp -o bin/main

Code

    #include <iostream>
    #include <concepts>
    #include <vector>
     
    
    auto addUnconstrained = [](auto fir, auto sec){ return fir + sec; };
    
    std::floating_point auto addConstrained(std::integral auto fir, 
                                            std::floating_point auto sec){
         return fir + sec;
    }
    
    int main() {
        std::cout << "Hello Easy C++ project!" << std::endl;
    
        std::cout << addUnconstrained(2000, 11.5);    // 2011.5
        std::cout << addConstrained(2000, 11.5);  // 2011.5
    }

i will be very appreciate if anyone help me.

thanks



Solution 1:[1]

output of compiling with "-v" following link. gist.github.com/RamazanDemirci/c43db2743792a5afa5b297456c03a423

Apple clang version 13.0.0 (clang-1300.0.29.30)
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

You were using the Apple Clang. Its implementation for concepts is not completed.

after brew install llvm command i got following output "Warning: llvm 13.0.1_1 is already installed and up-to-date."

If you have installed llvm-13 from Homebrew, run brew info llvm to find where it is installed. For my case, the command outputs

If you need to have llvm first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc

Then I can use /opt/homebrew/opt/llvm/bin/clang++. I also prepended the path into $PATH so that I can use clang++ directly to run it instead of Apple Clang.

Run with --version to check if it is regular/upstream Clang(the one from homebrew) or Apple Clang.

? /opt/homebrew/opt/llvm/bin/clang++ --version
Homebrew clang version 13.0.1
Target: arm64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1