boost_variant2.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Boost.Geometry
  2. // Copyright (c) 2021, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Licensed under the Boost Software License version 1.0.
  5. // http://www.boost.org/users/license.html
  6. #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT2_HPP
  7. #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT2_HPP
  8. #include <utility>
  9. #include <boost/variant2/variant.hpp>
  10. #include <boost/geometry/core/geometry_types.hpp>
  11. #include <boost/geometry/core/tag.hpp>
  12. #include <boost/geometry/core/tags.hpp>
  13. #include <boost/geometry/core/visit.hpp>
  14. #include <boost/geometry/util/sequence.hpp>
  15. namespace boost { namespace geometry
  16. {
  17. namespace traits
  18. {
  19. template <typename ...Ts>
  20. struct tag<boost::variant2::variant<Ts...>>
  21. {
  22. using type = dynamic_geometry_tag;
  23. };
  24. template <typename ...Ts>
  25. struct visit<boost::variant2::variant<Ts...>>
  26. {
  27. template <typename Function, typename Variant>
  28. static void apply(Function && function, Variant && variant)
  29. {
  30. boost::variant2::visit(std::forward<Function>(function),
  31. std::forward<Variant>(variant));
  32. }
  33. };
  34. template <typename ...Ts, typename ...Us>
  35. struct visit<boost::variant2::variant<Ts...>, boost::variant2::variant<Us...>>
  36. {
  37. template <typename Function, typename Variant1, typename Variant2>
  38. static void apply(Function && function, Variant1 && variant1, Variant2 && variant2)
  39. {
  40. boost::variant2::visit(std::forward<Function>(function),
  41. std::forward<Variant1>(variant1),
  42. std::forward<Variant2>(variant2));
  43. }
  44. };
  45. template <typename ...Ts>
  46. struct geometry_types<boost::variant2::variant<Ts...>>
  47. {
  48. using type = util::type_sequence<Ts...>;
  49. };
  50. } // namespace traits
  51. }} // namespace boost::geometry
  52. #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT2_HPP