Add BOOST_NULLPTR helper macro

This commit is contained in:
Peter Dimov
2022-05-23 02:29:23 +03:00
parent 26a8d38031
commit 663198ae92
3 changed files with 16 additions and 0 deletions

View File

@ -966,6 +966,10 @@ and must be defined for all translation units in the program, including Boost li
This macro will no longer have any effect once an official Microsoft This macro will no longer have any effect once an official Microsoft
release supports the CTP features. release supports the CTP features.
]] ]]
[[`BOOST_NULLPTR`][
If `BOOST_NO_CXX11_NULLPTR` is not defined (i.e. C++11 compliant compilers), expands to `nullptr`,
otherwise expands to `0`.
]]
] ]
[endsect] [endsect]

View File

@ -1069,6 +1069,12 @@ namespace std{ using ::type_info; }
#define BOOST_STATIC_CONSTEXPR static BOOST_CONSTEXPR_OR_CONST #define BOOST_STATIC_CONSTEXPR static BOOST_CONSTEXPR_OR_CONST
#if !defined(BOOST_NO_CXX11_NULLPTR)
# define BOOST_NULLPTR nullptr
#else
# define BOOST_NULLPTR 0
#endif
// //
// Set BOOST_HAS_STATIC_ASSERT when BOOST_NO_CXX11_STATIC_ASSERT is not defined // Set BOOST_HAS_STATIC_ASSERT when BOOST_NO_CXX11_STATIC_ASSERT is not defined
// //

View File

@ -62,6 +62,10 @@ struct trait
enum { value = b }; enum { value = b };
}; };
void* test_nullptr()
{
return BOOST_NULLPTR;
}
int main() int main()
{ {
@ -82,6 +86,8 @@ int main()
{ {
result += 2; result += 2;
} }
test_nullptr();
} }
catch(int) catch(int)
{ {