When the member of a class template that uses the requires clause is defined outside the class, gcc does not complain if requires is not specified, whereas clang does.
Consider the code snippet below:
#include <concepts>
template<typename Container>
requires std::integral<typename Container::value_type>
class Foo {
public:
void func();
};
template<typename Container>
void Foo<Container>::func()
{}
The compilation using gcc does not complain.
While clang reports the following error:
❯ clang++ -std=c++2a test.cpp
test.cpp:10:1: error: requires clause differs in template redeclaration
template<typename Container>
^
test.cpp:4:19: note: previous template declaration is here
requires std::integral<typename Container::value_type>
^
1 error generated.
If I change the definition as below:
template<typename Container>
requires std::integral<typename Container::value_type>
void Foo<Container>::func()
{}
now clang does not complain.
Output from gcc --version:
gcc (GCC) 10.2.0
Output from clang --version:
clang version 10.0.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Is this a bug to be reported?