variant_visit.hpp 790 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright Takatoshi Kondo 2020
  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_VARIANT_VISIT_HPP)
  7. #define MQTT_VARIANT_VISIT_HPP
  8. #include <ostream>
  9. #include <mqtt/namespace.hpp>
  10. #include <mqtt/variant.hpp>
  11. #include <mqtt/visitor_util.hpp>
  12. namespace MQTT_NS {
  13. #if defined(MQTT_STD_VARIANT)
  14. template<typename... Params>
  15. std::ostream& operator<<(std::ostream& os, variant<Params...> const& v) {
  16. MQTT_NS::visit(
  17. make_lambda_visitor(
  18. [&os] (auto const& e) {
  19. os << e;
  20. }
  21. ), v
  22. );
  23. return os;
  24. }
  25. #endif // defined(MQTT_USE_STD_VARIANT)
  26. } // namespace MQTT_NS
  27. #endif // MQTT_VARIANT_VISIT_HPP