of class?
template <class C> class X
{
public:
template <class T, typename std::enable_if< ! std::is_same<double,T>::value>::type * = nullptr > void get_as(){
std::cout << "get as T" << std::endl;
}
template <class T, typename std::enable_if< std::is_same<double,T>::value>::type * = nullptr > void get_as(){
std::cout << "get as double" << std::endl;
}
};
I did that like this but it does not works
template <class C>
class X
{
public:
template <class T,void* >
void get_as();
};
template <class C>
template <class T, typename std::enable_if< ! std::is_same<double,T>::value>::type * =nullptr>
void X<C>::get_as()
{
std::cout << "get as T" << std::endl;
}
template <class C>
template <class T, typename std::enable_if< std::is_same<double,T>::value>::type * =nullptr>
void X<C>::get_as()
{
std::cout << "get as double" << std::endl;
}
source code adapted from
http://stackoverflow.com/a/28697168/5134885
ofcource i find this on stackoverflow and i don't know why i can't move defination of this function outside of class (this is only for keeping my api clean . answer is right)
Обсуждают сегодня