Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:27

0001 
0002 #ifndef BOOST_CONTRACT_DETAIL_TVARIADIC_HPP_
0003 #define BOOST_CONTRACT_DETAIL_TVARIADIC_HPP_
0004 
0005 // Copyright (C) 2008-2018 Lorenzo Caminiti
0006 // Distributed under the Boost Software License, Version 1.0 (see accompanying
0007 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
0008 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
0009 
0010 #include <boost/config.hpp>
0011 #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
0012     #define BOOST_CONTRACT_DETAIL_TVARIADIC 0
0013 #else
0014     #define BOOST_CONTRACT_DETAIL_TVARIADIC 1
0015 #endif
0016 
0017 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0018     #include <tuple>
0019 
0020     /* CODE */
0021 
0022     namespace boost { namespace contract { namespace detail {
0023             namespace tvariadic_ {
0024         template<int...> struct indexes {};
0025 
0026         template<int N, int... I> struct indexes_of :
0027                 indexes_of<N - 1, N - 1, I...> {};
0028         template<int... I> struct indexes_of<0, I...>
0029                 { typedef indexes<I...> type; };
0030     } } } } // namespace
0031 
0032 #else
0033     #include <boost/preprocessor/repetition/enum.hpp>
0034     #include <boost/preprocessor/repetition/repeat.hpp>
0035     #include <boost/preprocessor/tuple/elem.hpp>
0036     #include <boost/preprocessor/punctuation/comma_if.hpp>
0037     #include <boost/preprocessor/cat.hpp>
0038 
0039     /* PRIVATE */
0040 
0041     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_ELEM_(z, n, tuple) \
0042         BOOST_PP_CAT(tuple, n)
0043     
0044     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INIT_(z, n, tuplevar_values) \
0045         BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, tuplevar_values), n)( \
0046                 BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, tuplevar_values), n))
0047 
0048     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_(z, n, type_qualifier_name) \
0049         BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 0, type_qualifier_name), n) \
0050             BOOST_PP_TUPLE_ELEM(3, 1, type_qualifier_name) \
0051             BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 2, type_qualifier_name), n) \
0052         ;
0053 
0054     #define BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_(z, n, tokens) \
0055         tokens
0056      
0057     #define BOOST_CONTRACT_DETAIL_TVARIADIC_ARG_(z, n, name) \
0058         BOOST_PP_CAT(name, n)
0059     
0060     #define BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAM_(z, n, type_qualifier_name) \
0061         BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 0, type_qualifier_name), n) \
0062         BOOST_PP_TUPLE_ELEM(3, 1, type_qualifier_name) \
0063         BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 2, type_qualifier_name), n)
0064     
0065     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAM_(z, n, name) \
0066         typename BOOST_PP_CAT(name, n)
0067 #endif
0068 
0069 /* PUBLIC */
0070 
0071 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0072     #define BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \
0073         ,
0074 #else
0075     #define BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \
0076         BOOST_PP_COMMA_IF(arity)
0077 #endif
0078 
0079 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0080     #define BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA(arity) /* nothing */
0081 #else
0082     #define BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA(arity) \
0083         BOOST_PP_COMMA_IF(arity)
0084 #endif
0085 
0086 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0087     #define BOOST_CONTRACT_DETAIL_TVARIADIC_SIZEOF(arity, name) sizeof...(name)
0088 #else
0089     #define BOOST_CONTRACT_DETAIL_TVARIADIC_SIZEOF(arity, name) arity
0090 #endif
0091 
0092 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0093     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(z, arity, name) \
0094         typename... name
0095 #else
0096     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(z, arity, name) \
0097         BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAM_, \
0098                 name)
0099 #endif
0100 
0101 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0102     #define BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z( \
0103             z, arity, type, qualifier, name) \
0104         type qualifier ... name
0105 #else
0106     #define BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z( \
0107             z, arity, type, qualifier, name) \
0108         BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAM_, \
0109                 (type, qualifier, name))
0110 #endif
0111 
0112 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0113     #define BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(z, arity, name) \
0114         name...
0115 #else
0116     #define BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(z, arity, name) \
0117         BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_ARG_, name)
0118 #endif
0119 
0120 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0121     #define BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(z, arity, tokens) \
0122         /* nothing */
0123 #else
0124     #define BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(z, arity, tokens) \
0125         BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_, \
0126                 tokens)
0127 #endif
0128 
0129 // Tuple.
0130 
0131 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0132     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_Z( \
0133             z, arity, type, qualifier, name) \
0134         std::tuple<type qualifier ...> name;
0135 #else
0136     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_Z( \
0137             z, arity, type, qualifier, name) \
0138         BOOST_PP_REPEAT_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_, \
0139                 (type, qualifier, name))
0140 #endif
0141 
0142 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0143     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INIT_Z(z, \
0144             arity, tuple, values) \
0145         tuple(values...)
0146 #else
0147     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INIT_Z(z, \
0148             arity, tuple, values) \
0149         BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INIT_,\
0150                 (tuple, values))
0151 #endif
0152 
0153 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0154     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_TPARAM(indexes) \
0155         int... indexes
0156 #else
0157     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_TPARAM(indexes) \
0158         /* nothing */
0159 #endif
0160 
0161 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0162     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_FPARAM(_indexes) \
0163         boost::contract::detail::tvariadic_::indexes<_indexes...>
0164 #else
0165     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_FPARAM(_indexes) \
0166         /* nothing */
0167 #endif
0168 
0169 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0170     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_OF(tuple_type) \
0171         typename boost::contract::detail::tvariadic_::indexes_of< \
0172                 sizeof...(tuple_type)>::type()
0173 #else
0174     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_OF(unused) \
0175         /* nothing */
0176 #endif
0177 
0178 #if BOOST_CONTRACT_DETAIL_TVARIADIC
0179     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_ELEMS_Z( \
0180             z, arity, indexes, tuple) \
0181         std::get<indexes>(tuple)...
0182 #else
0183     #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_ELEMS_Z( \
0184             z, arity, indexes, tuple) \
0185         BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_ELEM_,\
0186                 tuple)
0187 #endif
0188 
0189 #endif // #include guard
0190