I'm sorry for the weird title of this thread but I'm really not sure what I'm currently experience.
The problem I am experiencing is that devel/llvm13 doesn't know about
Minimum test case as follows:
main.cpp:
CMakeLists.txt:
Compilation output:
The test case above compiles fine with both devel/gcc10 and devel/gcc11. But also devel/llvm-devel is struggling on this one.
I'm aware that
The confusing part is that the same code on godbolt works fine, even when explicitly stating the use of
This would indicate that
Could somebody explain to me what I'm missing here?
The problem I am experiencing is that devel/llvm13 doesn't know about
std::invocable
.Minimum test case as follows:
main.cpp:
Code:
#include <concepts>
void func(int);
int main()
{
return std::invocable<decltype(&func), int>;
}
CMakeLists.txt:
Code:
cmake_minimum_required(VERSION 3.21)
project(llvm_test)
set(TARGET llvm_test)
add_executable(${TARGET})
target_compile_features(
${TARGET}
PRIVATE
cxx_std_20
)
target_sources(
${TARGET}
PRIVATE
main.cpp
)
Compilation output:
Code:
====================[ Build | llvm_test | Debug ]===============================
/usr/local/bin/cmake --build /home/jbo/projects/llvm_test/cmake-build-debug --target llvm_test -- -j 9
Scanning dependencies of target llvm_test
[ 50%] Building CXX object CMakeFiles/llvm_test.dir/main.cpp.o
/home/jbo/projects/llvm_test/main.cpp:6:42: error: expected '(' for function-style cast or type construction
return std::invocable<decltype(&func), int>;
~~~~~~~~~~~~~~~^
/home/jbo/projects/llvm_test/main.cpp:6:17: error: no member named 'invocable' in namespace 'std'
return std::invocable<decltype(&func), int>;
~~~~~^
2 errors generated.
gmake[3]: *** [CMakeFiles/llvm_test.dir/build.make:72: CMakeFiles/llvm_test.dir/main.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:83: CMakeFiles/llvm_test.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:90: CMakeFiles/llvm_test.dir/rule] Error 2
gmake: *** [Makefile:124: llvm_test] Error 2
The test case above compiles fine with both devel/gcc10 and devel/gcc11. But also devel/llvm-devel is struggling on this one.
I'm aware that
std::invocable
is a concept provided by the STL. It's not a compiler built-in language feature. Clang by default uses libc++
.The confusing part is that the same code on godbolt works fine, even when explicitly stating the use of
libc++
: https://godbolt.org/z/1P9b549qaThis would indicate that
libc++
shipping with clang 13 implements std::invocable
.Could somebody explain to me what I'm missing here?