addressof_np_test.cpp 853 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // Copyright 2013 Peter Dimov
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #include <boost/utility/addressof.hpp>
  9. #include <boost/detail/lightweight_test.hpp>
  10. #include <cstddef>
  11. #if defined( BOOST_NO_CXX11_NULLPTR )
  12. void nullptr_test()
  13. {
  14. }
  15. #else
  16. void nullptr_test()
  17. {
  18. {
  19. auto x = nullptr;
  20. BOOST_TEST( boost::addressof(x) == &x );
  21. }
  22. {
  23. auto const x = nullptr;
  24. BOOST_TEST( boost::addressof(x) == &x );
  25. }
  26. {
  27. auto volatile x = nullptr;
  28. BOOST_TEST( boost::addressof(x) == &x );
  29. }
  30. {
  31. auto const volatile x = nullptr;
  32. BOOST_TEST( boost::addressof(x) == &x );
  33. }
  34. }
  35. #endif
  36. int main()
  37. {
  38. nullptr_test();
  39. return boost::report_errors();
  40. }