sp_constexpr_test2.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // sp_constexpr_test2.cpp
  3. //
  4. // Copyright 2017 Peter Dimov
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt
  9. //
  10. #include <boost/config.hpp>
  11. #include <boost/detail/workaround.hpp>
  12. #define HAVE_CONSTEXPR_INIT
  13. #if defined( BOOST_NO_CXX11_CONSTEXPR )
  14. # undef HAVE_CONSTEXPR_INIT
  15. #endif
  16. #if BOOST_WORKAROUND( BOOST_MSVC, < 1930 )
  17. # undef HAVE_CONSTEXPR_INIT
  18. #endif
  19. #if defined(__clang__) && defined( BOOST_NO_CXX14_CONSTEXPR )
  20. # undef HAVE_CONSTEXPR_INIT
  21. #endif
  22. #if !defined( HAVE_CONSTEXPR_INIT )
  23. int main()
  24. {
  25. }
  26. #else
  27. #include <boost/shared_ptr.hpp>
  28. #include <boost/weak_ptr.hpp>
  29. #include <boost/enable_shared_from_this.hpp>
  30. #include <boost/core/lightweight_test.hpp>
  31. struct X: public boost::enable_shared_from_this<X>
  32. {
  33. int v_;
  34. constexpr X() BOOST_NOEXCEPT: v_( 1 )
  35. {
  36. }
  37. };
  38. struct Z
  39. {
  40. Z();
  41. };
  42. static Z z;
  43. static X x;
  44. Z::Z()
  45. {
  46. BOOST_TEST_EQ( x.v_, 1 );
  47. }
  48. int main()
  49. {
  50. return boost::report_errors();
  51. }
  52. #endif // #if defined( BOOST_NO_CXX11_CONSEXPR )