I'm falling into a problem, so I want to avoid this problem which is: if I provide a class template, I have to ensure that when I enter string it returns false, it worked for primitive data type but for this class template no.
template<class Y>
class Point
{
Y x, y;
public:
Point(){}
Point(Y _x, Y _y):x(_x),y(_y){}
~Point(){}
Point<Y>& operator++()
{
++x;
++y;
return *this;
}
};
Point<int>Pi;
template< typename, typename = void >
struct is_incrementable : std::false_type { };
template< typename T >
struct is_incrementable<T,std::void_t<decltype(++std::declval<T&>())>> : std::true_type { };
int main()
{
cout << boolalpha;
cout << is_incrementable<Point<int>>();
return 0;
}
how can I resolve that?