optional.hpp 928 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright Takatoshi Kondo 2018
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #if !defined(MQTT_OPTIONAL_HPP)
  7. #define MQTT_OPTIONAL_HPP
  8. #if defined(MQTT_STD_OPTIONAL)
  9. #include <optional>
  10. #else // defined(MQTT_STD_OPTIONAL)
  11. #include <boost/optional.hpp>
  12. #endif // defined(MQTT_STD_VARIANT)
  13. #include <mqtt/namespace.hpp>
  14. namespace MQTT_NS {
  15. #if defined(MQTT_STD_OPTIONAL)
  16. using std::optional;
  17. using std::nullopt_t;
  18. using in_place_t = std::in_place_t;
  19. static constexpr auto in_place_init = in_place_t{};
  20. static constexpr auto nullopt = std::nullopt;
  21. #else // defined(MQTT_STD_OPTIONAL)
  22. using boost::optional;
  23. using nullopt_t = boost::none_t;
  24. using boost::in_place_init;
  25. static const auto nullopt = boost::none;
  26. #endif // defined(MQTT_STD_OPTIONAL)
  27. } // namespace MQTT_NS
  28. #endif // MQTT_OPTIONAL_HPP