Merge pull request #431 from boostorg/pr/boost-nullptr

Add BOOST_NULLPTR helper macro
This commit is contained in:
jzmaddock
2022-06-05 12:50:15 +01:00
committed by GitHub
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
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]

View File

@ -1069,6 +1069,12 @@ namespace std{ using ::type_info; }
#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
//

View File

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