]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/assign/include/boost/assign/ptr_list_inserter.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / assign / include / boost / assign / ptr_list_inserter.hpp
CommitLineData
7c673cae
FG
1// Boost.Assign library
2//
3// Copyright Thorsten Ottosen 2003-2005. Use, modification and
4// distribution is subject to the Boost Software License, Version
5// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7//
8// For more information, see http://www.boost.org/libs/assign/
9//
10
11#ifndef BOOST_ASSIGN_PTR_LIST_INSERTER_HPP
12#define BOOST_ASSIGN_PTR_LIST_INSERTER_HPP
13
14#if defined(_MSC_VER)
15# pragma once
16#endif
17
18#include <boost/assign/list_inserter.hpp>
19#include <boost/type_traits/remove_reference.hpp>
20#include <boost/type_traits/remove_pointer.hpp>
21
22namespace boost
23{
24
25namespace assign
26{
27 template< class Function, class Obj >
28 class ptr_list_inserter
29 {
30 typedef BOOST_DEDUCED_TYPENAME
31 remove_pointer< BOOST_DEDUCED_TYPENAME
32 remove_reference<Obj>::type >::type
33 obj_type;
34 public:
35
36 ptr_list_inserter( Function fun ) : insert_( fun )
37 {}
38
39 template< class Function2, class Obj2 >
40 ptr_list_inserter( const ptr_list_inserter<Function2,Obj2>& r )
41 : insert_( r.fun_private() )
42 {}
43
44 ptr_list_inserter( const ptr_list_inserter& r ) : insert_( r.insert_ )
45 {}
46
47 ptr_list_inserter& operator()()
48 {
49 insert_( new obj_type() );
50 return *this;
51 }
52
53 template< class T >
54 ptr_list_inserter& operator()( const T& t )
55 {
56 insert_( new obj_type(t) );
57 return *this;
58 }
59
60#ifndef BOOST_ASSIGN_MAX_PARAMS // use user's value
61#define BOOST_ASSIGN_MAX_PARAMS 5
62#endif
63#define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1)
64#define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class T)
65#define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& t)
66#define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, t)
67
68#define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
69#define BOOST_PP_LOCAL_MACRO(n) \
70 template< class T, BOOST_ASSIGN_PARAMS1(n) > \
71 ptr_list_inserter& operator()( const T& t, BOOST_ASSIGN_PARAMS2(n) ) \
72 { \
73 insert_( new obj_type(t, BOOST_ASSIGN_PARAMS3(n) )); \
74 return *this; \
75 } \
76 /**/
77
78#include BOOST_PP_LOCAL_ITERATE()
79
80 private:
81
82 ptr_list_inserter& operator=( const ptr_list_inserter& );
83 Function insert_;
84 };
85
86 template< class Obj, class Function >
87 inline ptr_list_inserter< Function, Obj >
88 make_ptr_list_inserter( Function fun )
89 {
90 return ptr_list_inserter< Function, Obj >( fun );
91 }
92
93 template< class C >
94 inline ptr_list_inserter< assign_detail::call_push_back<C>,
95 BOOST_DEDUCED_TYPENAME C::reference >
96 ptr_push_back( C& c )
97 {
98 return make_ptr_list_inserter<BOOST_DEDUCED_TYPENAME C::reference>
99 ( assign_detail::call_push_back<C>( c ) );
100 }
101
102#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
103
104 template< class T, class C >
105 inline ptr_list_inserter< assign_detail::call_push_back<C>, T >
106 ptr_push_back( C& c )
107 {
108 return make_ptr_list_inserter<T>(
109 assign_detail::call_push_back<C>( c ) );
110 }
111
112#endif
113
114 template< class C >
115 inline ptr_list_inserter< assign_detail::call_push_front<C>,
116 BOOST_DEDUCED_TYPENAME C::reference >
117 ptr_push_front( C& c )
118 {
119 return make_ptr_list_inserter<BOOST_DEDUCED_TYPENAME C::reference>
120 ( assign_detail::call_push_front<C>( c ) );
121 }
122
123#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
124
125 template< class T, class C >
126 inline ptr_list_inserter< assign_detail::call_push_front<C>, T >
127 ptr_push_front( C& c )
128 {
129 return make_ptr_list_inserter<T>(
130 assign_detail::call_push_front<C>( c ) );
131 }
132
133#endif
134
135 template< class C >
136 inline ptr_list_inserter< assign_detail::call_insert<C>,
137 BOOST_DEDUCED_TYPENAME C::reference>
138 ptr_insert( C& c )
139 {
140 return make_ptr_list_inserter<BOOST_DEDUCED_TYPENAME C::reference>
141 ( assign_detail::call_insert<C>( c ) );
142 }
143
144#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
145
146 template< class T, class C >
147 inline ptr_list_inserter< assign_detail::call_insert<C>, T >
148 ptr_insert( C& c )
149 {
150 return make_ptr_list_inserter<T>( assign_detail::call_insert<C>( c ) );
151 }
152
153#endif
154
155
156} // namespace 'assign'
157} // namespace 'boost'
158
159#undef BOOST_ASSIGN_PARAMS1
160#undef BOOST_ASSIGN_PARAMS2
161#undef BOOST_ASSIGN_PARAMS3
162#undef BOOST_ASSIGN_MAX_PARAMETERS
163
164#endif