In such a situation I tend to define my own nullptr:
struct nullptr_t
{
template<class T> operator T* () const { return 0; }
} nullptr;
and use that instead of NULL.
Thanks, Peter. Both casting and nullptr worked fine. But it brings me to
a bigger question, should I bother replacing this code:
struct c{void f(char*){}};
typedef std::map TMap;
TMap a;
for(TMap::iterator i=a.begin();i!=a.end();++i)(*a)->second.f(NULL):
with the more complex code like this:
struct c{void f(char*){}};
struct nullptr_t{template<class T>operator T*()const{return 0;}}nullptr;
typedef std::map TMap;
TMap a;
std::for_each(a.begin(),a.end(),
boost::bind(&c::f,
boost::bind(&TMap::value_type::second,_1),
nullptr)
);
I know there should be a line. But I am new to the algorithm's way :)
Thanks.
--
Regards,
Alexander. http://sjcomp.com