File indexing completed on 2025-01-18 09:29:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASSIGN_PTR_LIST_INSERTER_HPP
0012 #define BOOST_ASSIGN_PTR_LIST_INSERTER_HPP
0013
0014 #if defined(_MSC_VER)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/assign/list_inserter.hpp>
0019 #include <boost/type_traits/remove_reference.hpp>
0020 #include <boost/type_traits/remove_pointer.hpp>
0021 #include <boost/move/utility.hpp>
0022
0023 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0024
0025 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
0026 #include <boost/preprocessor/repetition/enum_params.hpp>
0027 #include <boost/preprocessor/iteration/local.hpp>
0028
0029 #endif
0030
0031 namespace boost
0032 {
0033
0034 namespace assign
0035 {
0036 template< class Function, class Obj >
0037 class ptr_list_inserter
0038 {
0039 typedef BOOST_DEDUCED_TYPENAME
0040 remove_pointer< BOOST_DEDUCED_TYPENAME
0041 remove_reference<Obj>::type >::type
0042 obj_type;
0043 public:
0044
0045 ptr_list_inserter( Function fun ) : insert_( fun )
0046 {}
0047
0048 template< class Function2, class Obj2 >
0049 ptr_list_inserter( const ptr_list_inserter<Function2,Obj2>& r )
0050 : insert_( r.fun_private() )
0051 {}
0052
0053 ptr_list_inserter( const ptr_list_inserter& r ) : insert_( r.insert_ )
0054 {}
0055
0056
0057 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0058 ptr_list_inserter& operator()()
0059 {
0060 insert_( new obj_type() );
0061 return *this;
0062 }
0063
0064 template< class T >
0065 ptr_list_inserter& operator()( const T& t )
0066 {
0067 insert_( new obj_type(t) );
0068 return *this;
0069 }
0070
0071 #ifndef BOOST_ASSIGN_MAX_PARAMS
0072 #define BOOST_ASSIGN_MAX_PARAMS 5
0073 #endif
0074 #define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1)
0075 #define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class T)
0076 #define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& t)
0077 #define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, t)
0078
0079 #define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
0080 #define BOOST_PP_LOCAL_MACRO(n) \
0081 template< class T, BOOST_ASSIGN_PARAMS1(n) > \
0082 ptr_list_inserter& operator()( const T& t, BOOST_ASSIGN_PARAMS2(n) ) \
0083 { \
0084 insert_( new obj_type(t, BOOST_ASSIGN_PARAMS3(n) )); \
0085 return *this; \
0086 } \
0087
0088
0089 #include BOOST_PP_LOCAL_ITERATE()
0090
0091 #else
0092
0093 template< class... Ts >
0094 ptr_list_inserter& operator()(Ts&&... ts)
0095 {
0096 insert_(new obj_type(boost::forward<Ts>(ts)...));
0097 return *this;
0098 }
0099
0100 #endif
0101
0102 private:
0103
0104 ptr_list_inserter& operator=( const ptr_list_inserter& );
0105 Function insert_;
0106 };
0107
0108 template< class Obj, class Function >
0109 inline ptr_list_inserter< Function, Obj >
0110 make_ptr_list_inserter( Function fun )
0111 {
0112 return ptr_list_inserter< Function, Obj >( fun );
0113 }
0114
0115 template< class C >
0116 inline ptr_list_inserter< assign_detail::call_push_back<C>,
0117 BOOST_DEDUCED_TYPENAME C::reference >
0118 ptr_push_back( C& c )
0119 {
0120 return make_ptr_list_inserter<BOOST_DEDUCED_TYPENAME C::reference>
0121 ( assign_detail::call_push_back<C>( c ) );
0122 }
0123
0124 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
0125
0126 template< class T, class C >
0127 inline ptr_list_inserter< assign_detail::call_push_back<C>, T >
0128 ptr_push_back( C& c )
0129 {
0130 return make_ptr_list_inserter<T>(
0131 assign_detail::call_push_back<C>( c ) );
0132 }
0133
0134 #endif
0135
0136 template< class C >
0137 inline ptr_list_inserter< assign_detail::call_push_front<C>,
0138 BOOST_DEDUCED_TYPENAME C::reference >
0139 ptr_push_front( C& c )
0140 {
0141 return make_ptr_list_inserter<BOOST_DEDUCED_TYPENAME C::reference>
0142 ( assign_detail::call_push_front<C>( c ) );
0143 }
0144
0145 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
0146
0147 template< class T, class C >
0148 inline ptr_list_inserter< assign_detail::call_push_front<C>, T >
0149 ptr_push_front( C& c )
0150 {
0151 return make_ptr_list_inserter<T>(
0152 assign_detail::call_push_front<C>( c ) );
0153 }
0154
0155 #endif
0156
0157 template< class C >
0158 inline ptr_list_inserter< assign_detail::call_insert<C>,
0159 BOOST_DEDUCED_TYPENAME C::reference>
0160 ptr_insert( C& c )
0161 {
0162 return make_ptr_list_inserter<BOOST_DEDUCED_TYPENAME C::reference>
0163 ( assign_detail::call_insert<C>( c ) );
0164 }
0165
0166 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
0167
0168 template< class T, class C >
0169 inline ptr_list_inserter< assign_detail::call_insert<C>, T >
0170 ptr_insert( C& c )
0171 {
0172 return make_ptr_list_inserter<T>( assign_detail::call_insert<C>( c ) );
0173 }
0174
0175 #endif
0176
0177
0178 }
0179 }
0180
0181 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0182
0183 #undef BOOST_ASSIGN_PARAMS1
0184 #undef BOOST_ASSIGN_PARAMS2
0185 #undef BOOST_ASSIGN_PARAMS3
0186 #undef BOOST_ASSIGN_MAX_PARAMETERS
0187
0188 #endif
0189
0190 #endif