I have a class defined by two templates.
template<typename A, typename B> my_class {
private:
A value;
public:
operator A () {
return this->value;
}
};
I want to define an implicit conversion between the class and the first type in the template, but only for a specific second type on the template. Since A
is a C++ primitive type I can't define the conversion on that side. I tried std::enable_if
like this
operator typename std::enable_if<std::is_same<B, specific_B_type>::value, NumT>::type () {
return this->value;
}
but I get the compile error
Error C2833 'operator type' is not a recognized operator or type dimensional_analysis
Is there any way to do this without having to define the entire class specialized for B = specific_B_type
?