What is the correct syntax for explicit instantiation of conversion operators?
I have the following header a.h
class A
{
public:
template<typename T> operator T();
};
and the implementation a.cxx
#include "a.h"
template<typename T> A::operator T() {return 1;}
template A::operator int();
GCC 6.3 compiles as expected, but VC 14 (Visual Studio 2015) says:
error C2549: user-defined conversion cannot specify a return type
Is this an error in my code or a bug in VC? What would be the correct syntax vor VC?
#include "a.h" #include
int main()
{
A a;
auto b = static_cast(a);
std::cout << b << std::endl;
return 0;
}
. Without explicit instantiation it gives a link time error. – Helmut Zeisel Mar 09 '17 at 12:16