Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:10:13

0001 // Boost.TypeErasure library
0002 //
0003 // Copyright 2011 Steven Watanabe
0004 //
0005 // Distributed under the Boost Software License Version 1.0. (See
0006 // accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // $Id$
0010 
0011 #if !defined(BOOST_PP_IS_ITERATING)
0012 
0013 #ifndef BOOST_TYPE_ERASURE_CONSTRUCTIBLE_HPP_INCLUDED
0014 #define BOOST_TYPE_ERASURE_CONSTRUCTIBLE_HPP_INCLUDED
0015 
0016 #include <boost/detail/workaround.hpp>
0017 #include <boost/preprocessor/iteration/iterate.hpp>
0018 #include <boost/preprocessor/repetition/enum_params.hpp>
0019 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
0020 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
0021 #include <boost/type_erasure/detail/storage.hpp>
0022 #include <boost/type_erasure/call.hpp>
0023 #include <boost/type_erasure/concept_interface.hpp>
0024 #include <boost/type_erasure/config.hpp>
0025 #include <boost/type_erasure/param.hpp>
0026 
0027 namespace boost {
0028 namespace type_erasure {
0029 
0030 template<class Sig>
0031 struct constructible;
0032 
0033 namespace detail {
0034     
0035 template<class Sig>
0036 struct null_construct;
0037 
0038 template<class C>
0039 struct get_null_vtable_entry;
0040 
0041 template<class C, class Sig>
0042 struct vtable_adapter;
0043 
0044 }
0045 
0046 #ifdef BOOST_TYPE_ERASURE_DOXYGEN
0047 
0048 /**
0049  * The @ref constructible concept enables calling the
0050  * constructor of a type contained by an @ref any.
0051  * @c Sig should be a function signature.  The return
0052  * type is the placeholder specifying the type to
0053  * be constructed.  The arguments are the argument
0054  * types of the constructor.  The arguments of
0055  * @c Sig may be placeholders.
0056  *
0057  * \note @ref constructible may not be specialized and
0058  * may not be passed to \call as it depends on the
0059  * implementation details of @ref any.
0060  */
0061 template<class Sig>
0062 struct constructible {};
0063 
0064 #elif !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
0065     !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
0066     !BOOST_WORKAROUND(BOOST_MSVC, == 1800)
0067 
0068 template<class R, class... T>
0069 struct constructible<R(T...)>
0070 {
0071     static ::boost::type_erasure::detail::storage
0072     apply(T... arg)
0073     {
0074         ::boost::type_erasure::detail::storage result;
0075         result.data = new R(::std::forward<T>(arg)...);
0076         return result;
0077     }
0078 };
0079 
0080 /// INTERNAL ONLY
0081 template<class Base, class Tag, class... T>
0082 struct concept_interface<
0083     ::boost::type_erasure::constructible<Tag(T...)>,
0084     Base,
0085     Tag
0086 > : Base
0087 {
0088     using Base::_boost_type_erasure_deduce_constructor;
0089     ::boost::type_erasure::constructible<Tag(T...)>*
0090     _boost_type_erasure_deduce_constructor(
0091         typename ::boost::type_erasure::as_param<Base, T>::type...) const
0092     {
0093         return 0;
0094     }
0095 };
0096 
0097 namespace detail {
0098 
0099 template<class... T>
0100 struct null_construct<void(T...)>
0101 {
0102     static ::boost::type_erasure::detail::storage
0103     value(T...)
0104     {
0105         ::boost::type_erasure::detail::storage result;
0106         result.data = 0;
0107         return result;
0108     }
0109 };
0110 
0111 template<class T, class R, class... U>
0112 struct get_null_vtable_entry<vtable_adapter<constructible<T(const T&)>, R(U...)> >
0113 {
0114     typedef null_construct<void(U...)> type;
0115 };
0116 
0117 }
0118 
0119 #else
0120 
0121 #define BOOST_PP_FILENAME_1 <boost/type_erasure/constructible.hpp>
0122 #define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPE_ERASURE_MAX_ARITY)
0123 #include BOOST_PP_ITERATE()
0124 
0125 #endif
0126 
0127 }
0128 }
0129 
0130 #endif
0131 
0132 #else
0133 
0134 #define N BOOST_PP_ITERATION()
0135 
0136 #define BOOST_TYPE_ERASURE_ARG_DECL(z, n, data)     \
0137     typename ::boost::type_erasure::as_param<          \
0138         Base,                                       \
0139         BOOST_PP_CAT(T, n)                          \
0140     >::type
0141 
0142 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0143 #define BOOST_TYPE_ERASURE_FORWARD_I(z, n, data) ::std::forward<BOOST_PP_CAT(T, n)>(BOOST_PP_CAT(arg, n))
0144 #define BOOST_TYPE_ERASURE_FORWARD(n) BOOST_PP_ENUM(n, BOOST_TYPE_ERASURE_FORWARD_I, ~)
0145 #else
0146 #define BOOST_TYPE_ERASURE_FORWARD(n) BOOST_PP_ENUM_PARAMS(n, arg)
0147 #endif
0148 
0149 template<class R BOOST_PP_ENUM_TRAILING_PARAMS(N, class T)>
0150 struct constructible<R(BOOST_PP_ENUM_PARAMS(N, T))>
0151 {
0152     static ::boost::type_erasure::detail::storage
0153     apply(BOOST_PP_ENUM_BINARY_PARAMS(N, T, arg))
0154     {
0155         ::boost::type_erasure::detail::storage result;
0156         result.data = new R(BOOST_TYPE_ERASURE_FORWARD(N));
0157         return result;
0158     }
0159 };
0160 
0161 template<class Base BOOST_PP_ENUM_TRAILING_PARAMS(N, class T), class Tag>
0162 struct concept_interface<
0163     ::boost::type_erasure::constructible<Tag(BOOST_PP_ENUM_PARAMS(N, T))>,
0164     Base,
0165     Tag
0166 > : Base
0167 {
0168     using Base::_boost_type_erasure_deduce_constructor;
0169     ::boost::type_erasure::constructible<Tag(BOOST_PP_ENUM_PARAMS(N, T))>*
0170     _boost_type_erasure_deduce_constructor(
0171         BOOST_PP_ENUM(N, BOOST_TYPE_ERASURE_ARG_DECL, ~)) const
0172     {
0173         return 0;
0174     }
0175 };
0176 
0177 namespace detail {
0178 
0179 template<BOOST_PP_ENUM_PARAMS(N, class T)>
0180 struct null_construct<void(BOOST_PP_ENUM_PARAMS(N, T))>
0181 {
0182     static ::boost::type_erasure::detail::storage
0183     value(BOOST_PP_ENUM_PARAMS(N, T))
0184     {
0185         ::boost::type_erasure::detail::storage result;
0186         result.data = 0;
0187         return result;
0188     }
0189 };
0190 
0191 template<class T, class R BOOST_PP_ENUM_TRAILING_PARAMS(N, class T)>
0192 struct get_null_vtable_entry<vtable_adapter<constructible<T(const T&)>, R(BOOST_PP_ENUM_PARAMS(N, T))> >
0193 {
0194     typedef null_construct<void(BOOST_PP_ENUM_PARAMS(N, T))> type;
0195 };
0196 
0197 }
0198 
0199 #undef BOOST_TYPE_ERASURE_FORWARD
0200 #undef BOOST_TYPE_ERASURE_FORWARD_I
0201 
0202 #undef BOOST_TYPE_ERASURE_ARG_DECL
0203 #undef N
0204 
0205 #endif