Having issues finding a syntax for hoisting constrained member function outside of its class that GCC is happy with. At this point I'm starting to think it's a GCC bug.
struct S {
template<typename Idx>
static constexpr bool some_check = true;
template<typename Idx>
requires some_check<Idx>
void foo(Idx);
};
template<typename Idx>
requires S::template some_check<Idx>
void S::foo(Idx idx) {}
Clang accepts it but not GCC:
$ g++ -std=c++20 test.cpp
test.cpp:12:6: error: no declaration matches ‘void S::foo(Idx)’
12 | void S::foo(Idx idx) {}
| ^
test.cpp:7:10: note: candidate is: ‘template<class Idx> requires some_check<Idx> void S::foo(Idx)’
7 | void foo(Idx);
| ^~~
test.cpp:1:8: note: ‘struct S’ defined here
1 | struct S {
| ^
Is this program well-formed?
S::template some_checkin both places. OrS::some_check, assome_checkisn't a dependant name.templateis needed whenSwould depend on template parameter and it is impossible to tell whatS::some_checkis. So dropping this keyword fixes this, but also scope operator should be added in declaration: godbolt.org/z/WE9cMMox6 Apparently scope operator in declaration fixes all combinations.void foo(Idx) requires some_check<Idx>so that no need to spellS::template some_check. godbolt.org/z/fjMxKfGsj