Есть ли способ, с помощью какого-нибудь трюка с метапрограммированием, создать ситуацию, подобную этой:
int* get();//this fnc returns pointer to int OR nullptr
int k = 1;
//this is the operator which is supposed to compare value and pointer
template<class T>
bool operator!=(const T& left, const T* right)
{
if (right)
{
return left != *right;
}
else
{
return false;
}
}
//And this is the code fragment which interests me most
if (k != get())
{
///
}
Суть в том, что я не хотел бы изменять эту строку k! = Get (), и все же для некоторыхпричина мой оператор! = кажется, не работает.В чем проблема?