I have the following piece of C++17 code that uses class template deduction:
template <typename T>
struct Test {
T t;
Test(T t) : t(t) {}
bool check() { return true; }
};
template <typename T>
bool check(T t) {
return Test(t).check();
}
int main() {
return check(1);
}
gcc 8.2 compiles this without any problems, while clang 7.0 complains:
test.cpp:10:16: error: member reference base type 'Test' is not a structure or union
return Test(t).check();
~~~~~~~^~~~~~
I do not yet have a complete grasp of the intricacies of the class template argument deduction mechanism. Is this a bug in clang or am I using CTAD in a wrong way?
clang++ -std=c++17
. – Grevera