I need to call a templated conversion operator inside a class like this :
struct S {
template<typename T>
operator T() const {
return T{};
}
template<typename T>
T test()
{
return operator T();
}
};
int main(){
S s;
s.test<int>();
return 0;
}
This code compiles with clang but not with MSVC(19), gives me a c2352 error. Is the correct syntax?
Demo
Syntax is correct, as work around you might be explicit with this->operator T():
template<typename T>
T test()
{
return this->operator T();
}
Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With