none_t.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (C) 2003, Fernando Luis Cacciola Carballal.
  2. // Copyright (C) 2014, 2024 Andrzej Krzemienski.
  3. //
  4. // Use, modification, and distribution is subject to the Boost Software
  5. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // See http://www.boost.org/libs/optional for documentation.
  9. //
  10. // You are welcome to contact the author at:
  11. // fernando_cacciola@hotmail.com
  12. //
  13. #ifndef BOOST_NONE_T_17SEP2003_HPP
  14. #define BOOST_NONE_T_17SEP2003_HPP
  15. #include <boost/config.hpp>
  16. #include <boost/config/pragma_message.hpp>
  17. #if defined (BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \
  18. || defined(BOOST_NO_CXX11_LAMBDAS) || defined(BOOST_NO_CXX11_DECLTYPE_N3276) \
  19. || defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) \
  20. || defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) || defined(BOOST_NO_CXX11_STATIC_ASSERT)
  21. #error "Boost.Optional requires some C++11 features since version 1.87. If you have an older C++ version use Boost.Optional version 1.86 or earlier."
  22. #elif defined(BOOST_NO_CXX11_REF_QUALIFIERS) || defined(BOOST_NO_CXX11_NOEXCEPT) || defined(BOOST_NO_CXX11_DEFAULTED_MOVES)
  23. BOOST_PRAGMA_MESSAGE("C++03 support is deprecated in Boost.Optional 1.83 and will be removed in Boost.Optional 1.88.")
  24. #endif
  25. namespace boost {
  26. #ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
  27. namespace detail { struct none_helper{}; }
  28. typedef int detail::none_helper::*none_t ;
  29. #elif defined BOOST_OPTIONAL_USE_SINGLETON_DEFINITION_OF_NONE
  30. class none_t {};
  31. #else
  32. struct none_t
  33. {
  34. struct init_tag{};
  35. explicit BOOST_CONSTEXPR none_t(init_tag){} // to disable default constructor
  36. };
  37. #endif // old implementation workarounds
  38. } // namespace boost
  39. #endif // header guard