| 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-2023 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 | |
| 13 | #ifndef BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP |
| 14 | #define BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP |
| 15 | |
| 16 | #include <boost/variant/variant_fwd.hpp> |
| 17 | |
| 18 | #include <boost/mpl/list.hpp> |
| 19 | #include <boost/preprocessor/cat.hpp> |
| 20 | #include <boost/preprocessor/enum.hpp> |
| 21 | |
| 22 | namespace boost { |
| 23 | namespace detail { namespace variant { |
| 24 | |
| 25 | /////////////////////////////////////////////////////////////////////////////// |
| 26 | // (detail) metafunction make_variant_list |
| 27 | // |
| 28 | // Provides a MPL-compatible sequence with the specified non-void types |
| 29 | // as arguments. |
| 30 | // |
| 31 | // Rationale: see class template convert_void (variant_fwd.hpp) and using- |
| 32 | // declaration workaround (below). |
| 33 | // |
| 34 | |
| 35 | #if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) |
| 36 | |
| 37 | template < typename... T > |
| 38 | struct make_variant_list |
| 39 | { |
| 40 | typedef typename mpl::list< T... >::type type; |
| 41 | }; |
| 42 | |
| 43 | #else // defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) |
| 44 | |
| 45 | template < BOOST_VARIANT_ENUM_PARAMS(typename T) > |
| 46 | struct make_variant_list |
| 47 | { |
| 48 | public: // metafunction result |
| 49 | |
| 50 | // [Define a macro to convert any void(NN) tags to mpl::void...] |
| 51 | # define BOOST_VARIANT_AUX_CONVERT_VOID(z, N,_) \ |
| 52 | typename convert_void< BOOST_PP_CAT(T,N) >::type |
| 53 | |
| 54 | // [...so that the specified types can be passed to mpl::list...] |
| 55 | typedef typename mpl::list< |
| 56 | BOOST_PP_ENUM( |
| 57 | BOOST_VARIANT_LIMIT_TYPES |
| 58 | , BOOST_VARIANT_AUX_CONVERT_VOID |
| 59 | , _ |
| 60 | ) |
| 61 | >::type type; |
| 62 | |
| 63 | // [...and, finally, the conversion macro can be undefined:] |
| 64 | # undef BOOST_VARIANT_AUX_CONVERT_VOID |
| 65 | |
| 66 | }; |
| 67 | |
| 68 | #endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES workaround |
| 69 | |
| 70 | }} // namespace detail::variant |
| 71 | } // namespace boost |
| 72 | |
| 73 | #endif // BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP |
| 74 | |