make_variant_list.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //-----------------------------------------------------------------------------
  2. // boost variant/detail/make_variant_list.hpp header file
  3. // See http://www.boost.org for updates, documentation, and revision history.
  4. //-----------------------------------------------------------------------------
  5. //
  6. // Copyright (c) 2002-2003 Eric Friedman, Itay Maman
  7. // Copyright (c) 2013-2019 Antony Polukhin
  8. //
  9. // Distributed under the Boost Software License, Version 1.0. (See
  10. // accompanying file LICENSE_1_0.txt or copy at
  11. // http://www.boost.org/LICENSE_1_0.txt)
  12. #ifndef BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP
  13. #define BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP
  14. #include <boost/variant/variant_fwd.hpp>
  15. #include <boost/mpl/list.hpp>
  16. #include <boost/preprocessor/cat.hpp>
  17. #include <boost/preprocessor/enum.hpp>
  18. namespace boost {
  19. namespace detail { namespace variant {
  20. ///////////////////////////////////////////////////////////////////////////////
  21. // (detail) metafunction make_variant_list
  22. //
  23. // Provides a MPL-compatible sequence with the specified non-void types
  24. // as arguments.
  25. //
  26. // Rationale: see class template convert_void (variant_fwd.hpp) and using-
  27. // declaration workaround (below).
  28. //
  29. #if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
  30. template < typename... T >
  31. struct make_variant_list
  32. {
  33. typedef typename mpl::list< T... >::type type;
  34. };
  35. #else // defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
  36. template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
  37. struct make_variant_list
  38. {
  39. public: // metafunction result
  40. // [Define a macro to convert any void(NN) tags to mpl::void...]
  41. # define BOOST_VARIANT_AUX_CONVERT_VOID(z, N,_) \
  42. typename convert_void< BOOST_PP_CAT(T,N) >::type
  43. // [...so that the specified types can be passed to mpl::list...]
  44. typedef typename mpl::list<
  45. BOOST_PP_ENUM(
  46. BOOST_VARIANT_LIMIT_TYPES
  47. , BOOST_VARIANT_AUX_CONVERT_VOID
  48. , _
  49. )
  50. >::type type;
  51. // [...and, finally, the conversion macro can be undefined:]
  52. # undef BOOST_VARIANT_AUX_CONVERT_VOID
  53. };
  54. #endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES workaround
  55. }} // namespace detail::variant
  56. } // namespace boost
  57. #endif // BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP