Consider the following code which attempts to implement a partial specialization of class Bar
. In the first case, the foo
member function is defined inline and in the second case out of line. The out of line definition produces a compile error which I cannot figure out:
error: out-of-line definition of 'foo' from class 'Bar<T>' without definition
template<class T>
struct Bar;
template<class T>
requires std::is_same_v<T, int>
struct Bar<T> {
int foo(T a) {
return a 5;
}
};
template<class T>
requires std::is_same_v<T, double>
struct Bar<T> {
double foo(T a);
};
template<class T>
requires std::is_same_v<T, double>
double Bar<T>::foo(T a) {
return a 5;
};
I am using clang-11 with the c 20 compilation option. I am unsure if this is my misunderstanding, a feature or a bug. Any help is appreciated.
CodePudding user response:
Might be clang bug. It was reported at https://bugs.llvm.org/show_bug.cgi?id=50276. Anyway GCC is fine