Chris@16
|
1 /////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@16
|
3 // (C) Copyright Joaquin M Lopez Munoz 2006-2013
|
Chris@101
|
4 // (C) Copyright Ion Gaztanaga 2014-2014
|
Chris@16
|
5 //
|
Chris@16
|
6 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
7 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
8 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9 //
|
Chris@16
|
10 // See http://www.boost.org/libs/intrusive for documentation.
|
Chris@16
|
11 //
|
Chris@16
|
12 /////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
13
|
Chris@16
|
14 #ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
|
Chris@16
|
15 #define BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
|
Chris@16
|
16
|
Chris@101
|
17 #ifndef BOOST_CONFIG_HPP
|
Chris@101
|
18 # include <boost/config.hpp>
|
Chris@101
|
19 #endif
|
Chris@101
|
20
|
Chris@101
|
21 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@101
|
22 # pragma once
|
Chris@101
|
23 #endif
|
Chris@16
|
24
|
Chris@16
|
25 namespace boost {
|
Chris@16
|
26 namespace intrusive {
|
Chris@16
|
27 namespace detail {
|
Chris@16
|
28
|
Chris@101
|
29 #if defined(BOOST_MSVC) || defined(__BORLANDC_)
|
Chris@101
|
30 #define BOOST_INTRUSIVE_TT_DECL __cdecl
|
Chris@101
|
31 #else
|
Chris@101
|
32 #define BOOST_INTRUSIVE_TT_DECL
|
Chris@101
|
33 #endif
|
Chris@101
|
34
|
Chris@101
|
35 #if defined(_MSC_EXTENSIONS) && !defined(__BORLAND__) && !defined(_WIN64) && !defined(_M_ARM) && !defined(UNDER_CE)
|
Chris@101
|
36 #define BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
|
Chris@101
|
37 #endif
|
Chris@101
|
38
|
Chris@101
|
39 template <typename T>
|
Chris@101
|
40 struct is_unary_or_binary_function_impl
|
Chris@101
|
41 { static const bool value = false; };
|
Chris@101
|
42
|
Chris@101
|
43 // see boost ticket #4094
|
Chris@101
|
44 // avoid duplicate definitions of is_unary_or_binary_function_impl
|
Chris@101
|
45 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
|
Chris@101
|
46
|
Chris@101
|
47 template <typename R>
|
Chris@101
|
48 struct is_unary_or_binary_function_impl<R (*)()>
|
Chris@101
|
49 { static const bool value = true; };
|
Chris@101
|
50
|
Chris@101
|
51 template <typename R>
|
Chris@101
|
52 struct is_unary_or_binary_function_impl<R (*)(...)>
|
Chris@101
|
53 { static const bool value = true; };
|
Chris@101
|
54
|
Chris@101
|
55 #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
|
Chris@101
|
56
|
Chris@101
|
57 template <typename R>
|
Chris@101
|
58 struct is_unary_or_binary_function_impl<R (__stdcall*)()>
|
Chris@101
|
59 { static const bool value = true; };
|
Chris@101
|
60
|
Chris@101
|
61 #ifndef _MANAGED
|
Chris@101
|
62
|
Chris@101
|
63 template <typename R>
|
Chris@101
|
64 struct is_unary_or_binary_function_impl<R (__fastcall*)()>
|
Chris@101
|
65 { static const bool value = true; };
|
Chris@101
|
66
|
Chris@101
|
67 #endif
|
Chris@101
|
68
|
Chris@101
|
69 template <typename R>
|
Chris@101
|
70 struct is_unary_or_binary_function_impl<R (__cdecl*)()>
|
Chris@101
|
71 { static const bool value = true; };
|
Chris@101
|
72
|
Chris@101
|
73 template <typename R>
|
Chris@101
|
74 struct is_unary_or_binary_function_impl<R (__cdecl*)(...)>
|
Chris@101
|
75 { static const bool value = true; };
|
Chris@101
|
76
|
Chris@101
|
77 #endif
|
Chris@101
|
78
|
Chris@101
|
79 // see boost ticket #4094
|
Chris@101
|
80 // avoid duplicate definitions of is_unary_or_binary_function_impl
|
Chris@101
|
81 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
|
Chris@101
|
82
|
Chris@101
|
83 template <typename R, class T0>
|
Chris@101
|
84 struct is_unary_or_binary_function_impl<R (*)(T0)>
|
Chris@101
|
85 { static const bool value = true; };
|
Chris@101
|
86
|
Chris@101
|
87 template <typename R, class T0>
|
Chris@101
|
88 struct is_unary_or_binary_function_impl<R (*)(T0...)>
|
Chris@101
|
89 { static const bool value = true; };
|
Chris@101
|
90
|
Chris@101
|
91 #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
|
Chris@101
|
92
|
Chris@101
|
93 template <typename R, class T0>
|
Chris@101
|
94 struct is_unary_or_binary_function_impl<R (__stdcall*)(T0)>
|
Chris@101
|
95 { static const bool value = true; };
|
Chris@101
|
96
|
Chris@101
|
97 #ifndef _MANAGED
|
Chris@101
|
98
|
Chris@101
|
99 template <typename R, class T0>
|
Chris@101
|
100 struct is_unary_or_binary_function_impl<R (__fastcall*)(T0)>
|
Chris@101
|
101 { static const bool value = true; };
|
Chris@101
|
102
|
Chris@101
|
103 #endif
|
Chris@101
|
104
|
Chris@101
|
105 template <typename R, class T0>
|
Chris@101
|
106 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0)>
|
Chris@101
|
107 { static const bool value = true; };
|
Chris@101
|
108
|
Chris@101
|
109 template <typename R, class T0>
|
Chris@101
|
110 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0...)>
|
Chris@101
|
111 { static const bool value = true; };
|
Chris@101
|
112
|
Chris@101
|
113 #endif
|
Chris@101
|
114
|
Chris@101
|
115 // see boost ticket #4094
|
Chris@101
|
116 // avoid duplicate definitions of is_unary_or_binary_function_impl
|
Chris@101
|
117 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
|
Chris@101
|
118
|
Chris@101
|
119 template <typename R, class T0, class T1>
|
Chris@101
|
120 struct is_unary_or_binary_function_impl<R (*)(T0, T1)>
|
Chris@101
|
121 { static const bool value = true; };
|
Chris@101
|
122
|
Chris@101
|
123 template <typename R, class T0, class T1>
|
Chris@101
|
124 struct is_unary_or_binary_function_impl<R (*)(T0, T1...)>
|
Chris@101
|
125 { static const bool value = true; };
|
Chris@101
|
126
|
Chris@101
|
127 #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
|
Chris@101
|
128
|
Chris@101
|
129 template <typename R, class T0, class T1>
|
Chris@101
|
130 struct is_unary_or_binary_function_impl<R (__stdcall*)(T0, T1)>
|
Chris@101
|
131 { static const bool value = true; };
|
Chris@101
|
132
|
Chris@101
|
133 #ifndef _MANAGED
|
Chris@101
|
134
|
Chris@101
|
135 template <typename R, class T0, class T1>
|
Chris@101
|
136 struct is_unary_or_binary_function_impl<R (__fastcall*)(T0, T1)>
|
Chris@101
|
137 { static const bool value = true; };
|
Chris@101
|
138
|
Chris@101
|
139 #endif
|
Chris@101
|
140
|
Chris@101
|
141 template <typename R, class T0, class T1>
|
Chris@101
|
142 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1)>
|
Chris@101
|
143 { static const bool value = true; };
|
Chris@101
|
144
|
Chris@101
|
145 template <typename R, class T0, class T1>
|
Chris@101
|
146 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1...)>
|
Chris@101
|
147 { static const bool value = true; };
|
Chris@101
|
148 #endif
|
Chris@101
|
149
|
Chris@101
|
150 template <typename T>
|
Chris@101
|
151 struct is_unary_or_binary_function_impl<T&>
|
Chris@101
|
152 { static const bool value = false; };
|
Chris@101
|
153
|
Chris@101
|
154 template<typename T>
|
Chris@101
|
155 struct is_unary_or_binary_function : is_unary_or_binary_function_impl<T>
|
Chris@101
|
156 {};
|
Chris@101
|
157
|
Chris@16
|
158 template<typename T, bool IsEmpty = true>
|
Chris@16
|
159 class ebo_functor_holder_impl
|
Chris@16
|
160 {
|
Chris@16
|
161 public:
|
Chris@16
|
162 ebo_functor_holder_impl()
|
Chris@16
|
163 {}
|
Chris@16
|
164 ebo_functor_holder_impl(const T& t)
|
Chris@16
|
165 : t_(t)
|
Chris@16
|
166 {}
|
Chris@16
|
167 template<class Arg1, class Arg2>
|
Chris@16
|
168 ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2)
|
Chris@16
|
169 : t_(arg1, arg2)
|
Chris@16
|
170 {}
|
Chris@16
|
171
|
Chris@16
|
172 T& get(){return t_;}
|
Chris@16
|
173 const T& get()const{return t_;}
|
Chris@16
|
174
|
Chris@16
|
175 private:
|
Chris@16
|
176 T t_;
|
Chris@16
|
177 };
|
Chris@16
|
178
|
Chris@16
|
179 template<typename T>
|
Chris@16
|
180 class ebo_functor_holder_impl<T, false>
|
Chris@16
|
181 : public T
|
Chris@16
|
182 {
|
Chris@16
|
183 public:
|
Chris@16
|
184 ebo_functor_holder_impl()
|
Chris@16
|
185 {}
|
Chris@101
|
186 explicit ebo_functor_holder_impl(const T& t)
|
Chris@16
|
187 : T(t)
|
Chris@16
|
188 {}
|
Chris@16
|
189 template<class Arg1, class Arg2>
|
Chris@16
|
190 ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2)
|
Chris@16
|
191 : T(arg1, arg2)
|
Chris@16
|
192 {}
|
Chris@16
|
193
|
Chris@16
|
194 T& get(){return *this;}
|
Chris@16
|
195 const T& get()const{return *this;}
|
Chris@16
|
196 };
|
Chris@16
|
197
|
Chris@16
|
198 template<typename T>
|
Chris@16
|
199 class ebo_functor_holder
|
Chris@16
|
200 : public ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value>
|
Chris@16
|
201 {
|
Chris@16
|
202 private:
|
Chris@16
|
203 typedef ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value> super;
|
Chris@16
|
204
|
Chris@16
|
205 public:
|
Chris@16
|
206 ebo_functor_holder(){}
|
Chris@101
|
207 explicit ebo_functor_holder(const T& t)
|
Chris@16
|
208 : super(t)
|
Chris@16
|
209 {}
|
Chris@16
|
210
|
Chris@16
|
211 template<class Arg1, class Arg2>
|
Chris@16
|
212 ebo_functor_holder(const Arg1& arg1, const Arg2& arg2)
|
Chris@16
|
213 : super(arg1, arg2)
|
Chris@16
|
214 {}
|
Chris@16
|
215
|
Chris@16
|
216 ebo_functor_holder& operator=(const ebo_functor_holder& x)
|
Chris@16
|
217 {
|
Chris@16
|
218 this->get()=x.get();
|
Chris@16
|
219 return *this;
|
Chris@16
|
220 }
|
Chris@16
|
221 };
|
Chris@16
|
222
|
Chris@16
|
223
|
Chris@16
|
224 } //namespace detail {
|
Chris@16
|
225 } //namespace intrusive {
|
Chris@16
|
226 } //namespace boost {
|
Chris@16
|
227
|
Chris@16
|
228 #endif //#ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
|