Skip to content

Commit bfcbfe3

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents d022c85 + 5c1ed6a commit bfcbfe3

File tree

9 files changed

+118
-71
lines changed

9 files changed

+118
-71
lines changed

doc/accumulators.qbk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ calculates the mean and 2nd moment of a sequence of doubles.
101101

102102
// Display the results ...
103103
std::cout << "Mean: " << mean(acc) << std::endl;
104-
std::cout << "Moment: " << accumulators::moment<2>(acc) << std::endl;
104+
std::cout << "Moment: " << moment<2>(acc) << std::endl;
105105

106106
return 0;
107107
}

include/boost/accumulators/numeric/functional.hpp

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,9 @@ namespace boost { namespace numeric
9999
}; \
100100
template<typename Arg, typename EnableIf> \
101101
struct Name ## _base \
102-
: std::unary_function< \
103-
typename remove_const<Arg>::type \
104-
, typename result_of_ ## Name<Arg>::type \
105-
> \
106102
{ \
103+
typedef typename remove_const<Arg>::type argument_type; \
104+
typedef typename result_of_ ## Name<Arg>::type result_type; \
107105
typename result_of_ ## Name<Arg>::type operator ()(Arg &arg) const \
108106
{ \
109107
return Op arg; \
@@ -138,12 +136,10 @@ namespace boost { namespace numeric
138136
}; \
139137
template<typename Left, typename Right, typename EnableIf> \
140138
struct Name ## _base \
141-
: std::binary_function< \
142-
typename remove_const<Left>::type \
143-
, typename remove_const<Right>::type \
144-
, typename result_of_ ## Name<Left, Right>::type \
145-
> \
146139
{ \
140+
typedef typename remove_const<Left>::type first_argument_type; \
141+
typedef typename remove_const<Right>::type second_argument_type; \
142+
typedef typename result_of_ ## Name<Left, Right>::type result_type; \
147143
typename result_of_ ## Name<Left, Right>::type \
148144
operator ()(Left &left, Right &right) const \
149145
{ \
@@ -220,8 +216,11 @@ namespace boost { namespace numeric
220216
{
221217
template<typename Left, typename Right, typename EnableIf>
222218
struct min_assign_base
223-
: std::binary_function<Left, Right, void>
224219
{
220+
typedef Left first_argument_type;
221+
typedef Right second_argument_type;
222+
typedef void result_type;
223+
225224
void operator ()(Left &left, Right &right) const
226225
{
227226
if(numeric::less(right, left))
@@ -233,8 +232,11 @@ namespace boost { namespace numeric
233232

234233
template<typename Left, typename Right, typename EnableIf>
235234
struct max_assign_base
236-
: std::binary_function<Left, Right, void>
237235
{
236+
typedef Left first_argument_type;
237+
typedef Right second_argument_type;
238+
typedef void result_type;
239+
238240
void operator ()(Left &left, Right &right) const
239241
{
240242
if(numeric::greater(right, left))
@@ -258,8 +260,10 @@ namespace boost { namespace numeric
258260

259261
template<typename To, typename From, typename EnableIf>
260262
struct promote_base
261-
: std::unary_function<From, To>
262263
{
264+
typedef From argument_type;
265+
typedef To result_type;
266+
263267
To operator ()(From &from) const
264268
{
265269
return from;
@@ -268,8 +272,10 @@ namespace boost { namespace numeric
268272

269273
template<typename ToFrom>
270274
struct promote_base<ToFrom, ToFrom, void>
271-
: std::unary_function<ToFrom, ToFrom>
272275
{
276+
typedef ToFrom argument_type;
277+
typedef ToFrom result_type;
278+
273279
ToFrom &operator ()(ToFrom &tofrom)
274280
{
275281
return tofrom;
@@ -278,10 +284,12 @@ namespace boost { namespace numeric
278284

279285
template<typename Arg, typename EnableIf>
280286
struct as_min_base
281-
: std::unary_function<Arg, typename remove_const<Arg>::type>
282287
{
283288
BOOST_STATIC_ASSERT(std::numeric_limits<typename remove_const<Arg>::type>::is_specialized);
284289

290+
typedef Arg argument_type;
291+
typedef typename remove_const<Arg>::type result_type;
292+
285293
typename remove_const<Arg>::type operator ()(Arg &) const
286294
{
287295
return (std::numeric_limits<typename remove_const<Arg>::type>::min)();
@@ -290,10 +298,12 @@ namespace boost { namespace numeric
290298

291299
template<typename Arg>
292300
struct as_min_base<Arg, typename enable_if<is_floating_point<Arg> >::type>
293-
: std::unary_function<Arg, typename remove_const<Arg>::type>
294301
{
295302
BOOST_STATIC_ASSERT(std::numeric_limits<typename remove_const<Arg>::type>::is_specialized);
296303

304+
typedef Arg argument_type;
305+
typedef typename remove_const<Arg>::type result_type;
306+
297307
typename remove_const<Arg>::type operator ()(Arg &) const
298308
{
299309
return -(std::numeric_limits<typename remove_const<Arg>::type>::max)();
@@ -302,10 +312,12 @@ namespace boost { namespace numeric
302312

303313
template<typename Arg, typename EnableIf>
304314
struct as_max_base
305-
: std::unary_function<Arg, typename remove_const<Arg>::type>
306315
{
307316
BOOST_STATIC_ASSERT(std::numeric_limits<typename remove_const<Arg>::type>::is_specialized);
308317

318+
typedef Arg argument_type;
319+
typedef typename remove_const<Arg>::type result_type;
320+
309321
typename remove_const<Arg>::type operator ()(Arg &) const
310322
{
311323
return (std::numeric_limits<typename remove_const<Arg>::type>::max)();
@@ -314,8 +326,10 @@ namespace boost { namespace numeric
314326

315327
template<typename Arg, typename EnableIf>
316328
struct as_zero_base
317-
: std::unary_function<Arg, typename remove_const<Arg>::type>
318329
{
330+
typedef Arg argument_type;
331+
typedef typename remove_const<Arg>::type result_type;
332+
319333
typename remove_const<Arg>::type operator ()(Arg &) const
320334
{
321335
return numeric::zero<typename remove_const<Arg>::type>::value;
@@ -324,8 +338,10 @@ namespace boost { namespace numeric
324338

325339
template<typename Arg, typename EnableIf>
326340
struct as_one_base
327-
: std::unary_function<Arg, typename remove_const<Arg>::type>
328341
{
342+
typedef Arg argument_type;
343+
typedef typename remove_const<Arg>::type result_type;
344+
329345
typename remove_const<Arg>::type operator ()(Arg &) const
330346
{
331347
return numeric::one<typename remove_const<Arg>::type>::value;

include/boost/accumulators/numeric/functional/valarray.hpp

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,9 @@ namespace boost { namespace numeric
118118
#define BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(Name, Op) \
119119
template<typename Left, typename Right> \
120120
struct Name<Left, Right, std_valarray_tag, std_valarray_tag> \
121-
: std::binary_function< \
122-
Left \
123-
, Right \
124-
, std::valarray< \
125-
typename Name< \
126-
typename Left::value_type \
127-
, typename Right::value_type \
128-
>::result_type \
129-
> \
130-
> \
131121
{ \
122+
typedef Left first_argument_type; \
123+
typedef Right second_argument_type; \
132124
typedef typename Left::value_type left_value_type; \
133125
typedef typename Right::value_type right_value_type; \
134126
typedef \
@@ -145,14 +137,9 @@ namespace boost { namespace numeric
145137
}; \
146138
template<typename Left, typename Right> \
147139
struct Name<Left, Right, std_valarray_tag, void> \
148-
: std::binary_function< \
149-
Left \
150-
, Right \
151-
, std::valarray< \
152-
typename Name<typename Left::value_type, Right>::result_type \
153-
> \
154-
> \
155140
{ \
141+
typedef Left first_argument_type; \
142+
typedef Right second_argument_type; \
156143
typedef typename Left::value_type left_value_type; \
157144
typedef \
158145
std::valarray< \
@@ -167,14 +154,9 @@ namespace boost { namespace numeric
167154
}; \
168155
template<typename Left, typename Right> \
169156
struct Name<Left, Right, void, std_valarray_tag> \
170-
: std::binary_function< \
171-
Left \
172-
, Right \
173-
, std::valarray< \
174-
typename Name<Left, typename Right::value_type>::result_type \
175-
> \
176-
> \
177157
{ \
158+
typedef Left first_argument_type; \
159+
typedef Right second_argument_type; \
178160
typedef typename Right::value_type right_value_type; \
179161
typedef \
180162
std::valarray< \
@@ -200,8 +182,11 @@ namespace boost { namespace numeric
200182
// element-wise min of std::valarray
201183
template<typename Left, typename Right>
202184
struct min_assign<Left, Right, std_valarray_tag, std_valarray_tag>
203-
: std::binary_function<Left, Right, void>
204185
{
186+
typedef Left first_argument_type;
187+
typedef Right second_argument_type;
188+
typedef void result_type;
189+
205190
void operator ()(Left &left, Right &right) const
206191
{
207192
BOOST_ASSERT(left.size() == right.size());
@@ -219,8 +204,11 @@ namespace boost { namespace numeric
219204
// element-wise max of std::valarray
220205
template<typename Left, typename Right>
221206
struct max_assign<Left, Right, std_valarray_tag, std_valarray_tag>
222-
: std::binary_function<Left, Right, void>
223207
{
208+
typedef Left first_argument_type;
209+
typedef Right second_argument_type;
210+
typedef void result_type;
211+
224212
void operator ()(Left &left, Right &right) const
225213
{
226214
BOOST_ASSERT(left.size() == right.size());
@@ -247,8 +235,10 @@ namespace boost { namespace numeric
247235
// promote
248236
template<typename To, typename From>
249237
struct promote<To, From, std_valarray_tag, std_valarray_tag>
250-
: std::unary_function<From, To>
251238
{
239+
typedef From argument_type;
240+
typedef To result_type;
241+
252242
To operator ()(From &arr) const
253243
{
254244
typename remove_const<To>::type res(arr.size());
@@ -262,8 +252,10 @@ namespace boost { namespace numeric
262252

263253
template<typename ToFrom>
264254
struct promote<ToFrom, ToFrom, std_valarray_tag, std_valarray_tag>
265-
: std::unary_function<ToFrom, ToFrom>
266255
{
256+
typedef ToFrom argument_type;
257+
typedef ToFrom result_type;
258+
267259
ToFrom &operator ()(ToFrom &tofrom) const
268260
{
269261
return tofrom;
@@ -275,8 +267,10 @@ namespace boost { namespace numeric
275267
// if(numeric::promote<bool>(a == b))
276268
template<typename From>
277269
struct promote<bool, From, void, std_valarray_tag>
278-
: std::unary_function<From, bool>
279270
{
271+
typedef From argument_type;
272+
typedef bool result_type;
273+
280274
bool operator ()(From &arr) const
281275
{
282276
BOOST_MPL_ASSERT((is_same<bool, typename From::value_type>));
@@ -300,8 +294,10 @@ namespace boost { namespace numeric
300294
// functional::as_min
301295
template<typename T>
302296
struct as_min<T, std_valarray_tag>
303-
: std::unary_function<T, typename remove_const<T>::type>
304297
{
298+
typedef T argument_type;
299+
typedef typename remove_const<T>::type result_type;
300+
305301
typename remove_const<T>::type operator ()(T &arr) const
306302
{
307303
return 0 == arr.size()
@@ -314,8 +310,10 @@ namespace boost { namespace numeric
314310
// functional::as_max
315311
template<typename T>
316312
struct as_max<T, std_valarray_tag>
317-
: std::unary_function<T, typename remove_const<T>::type>
318313
{
314+
typedef T argument_type;
315+
typedef typename remove_const<T>::type result_type;
316+
319317
typename remove_const<T>::type operator ()(T &arr) const
320318
{
321319
return 0 == arr.size()
@@ -328,8 +326,10 @@ namespace boost { namespace numeric
328326
// functional::as_zero
329327
template<typename T>
330328
struct as_zero<T, std_valarray_tag>
331-
: std::unary_function<T, typename remove_const<T>::type>
332329
{
330+
typedef T argument_type;
331+
typedef typename remove_const<T>::type result_type;
332+
333333
typename remove_const<T>::type operator ()(T &arr) const
334334
{
335335
return 0 == arr.size()
@@ -342,8 +342,10 @@ namespace boost { namespace numeric
342342
// functional::as_one
343343
template<typename T>
344344
struct as_one<T, std_valarray_tag>
345-
: std::unary_function<T, typename remove_const<T>::type>
346345
{
346+
typedef T argument_type;
347+
typedef typename remove_const<T>::type result_type;
348+
347349
typename remove_const<T>::type operator ()(T &arr) const
348350
{
349351
return 0 == arr.size()

0 commit comments

Comments
 (0)