I am working on a library with two different end users, one of which uses gcc 4.5.3, and the other has just migrated to gcc 4.6.3. The library uses the new C ++ 11 smart pointers (particularly unique_ptr) and compiles in gcc 4.5.3. However, between these two versions, gcc began to support nullptr, so the unique_ptr API has changed more closely according to the standard. However, now the following code has gone from a fine to ambiguous
unique_ptr up( new int( 30 ) );
...
if( up == 0 )
Is there a clean (namely, the following sentence) way to modify the above if statement so that it works with or without a null value? I would like to avoid a configuration check and then a macro as shown below (which I think will work) if possible
#if defined NULLPOINTER_AVAILABLE
#define NULLPTR (nullptr)
#else
#define NULLPTR (0)
#endif
, ?