transform_variant.hpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2015-2020.
  6. // Modifications copyright (c) 2015-2020, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  8. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  9. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  10. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  11. // Use, modification and distribution is subject to the Boost Software License,
  12. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_UTIL_TRANSFORM_VARIANT_HPP
  15. #define BOOST_GEOMETRY_UTIL_TRANSFORM_VARIANT_HPP
  16. #include <boost/config/pragma_message.hpp>
  17. #if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
  18. BOOST_PRAGMA_MESSAGE("This header is deprecated.")
  19. #endif
  20. #include <boost/mpl/transform.hpp>
  21. #include <boost/variant/variant_fwd.hpp>
  22. namespace boost { namespace geometry
  23. {
  24. /*!
  25. \brief Meta-function that takes a Sequence type, an MPL lambda
  26. expression and an optional Inserter and returns a variant type over
  27. the same types as the initial variant type, each transformed using
  28. the lambda expression.
  29. \ingroup utility
  30. \par Example
  31. \code
  32. typedef boost::mpl::vector<int, float, long> types;
  33. typedef transform_variant<types, add_pointer<_> > transformed;
  34. typedef variant<int*, float*, long*> result;
  35. BOOST_MPL_ASSERT(( equal<result, transformed> ));
  36. \endcode
  37. */
  38. template <typename Sequence, typename Op, typename In = boost::mpl::na>
  39. struct transform_variant:
  40. make_variant_over<
  41. typename boost::mpl::transform<
  42. Sequence,
  43. Op,
  44. In
  45. >::type
  46. >
  47. {};
  48. /*!
  49. \brief Meta-function that takes a boost::variant type and an MPL lambda
  50. expression and returns a variant type over the same types as the
  51. initial variant type, each transformed using the lambda expression.
  52. \ingroup utility
  53. \par Example
  54. \code
  55. typedef variant<int, float, long> variant_type;
  56. typedef transform_variant<variant_type, add_pointer<_> > transformed;
  57. typedef variant<int*, float*, long*> result;
  58. BOOST_MPL_ASSERT(( equal<result, transformed> ));
  59. \endcode
  60. */
  61. template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Op>
  62. struct transform_variant<variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Op, boost::mpl::na> :
  63. make_variant_over<
  64. typename boost::mpl::transform<
  65. typename variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
  66. Op
  67. >::type
  68. >
  69. {};
  70. }} // namespace boost::geometry
  71. #endif // BOOST_GEOMETRY_UTIL_TRANSFORM_VARIANT_HPP