Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 // max.hpp
|
Chris@16
|
3 //
|
Chris@16
|
4 // Copyright 2005 Eric Niebler. Distributed under the Boost
|
Chris@16
|
5 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7
|
Chris@16
|
8 #ifndef BOOST_ACCUMULATORS_STATISTICS_MAX_HPP_EAN_28_10_2005
|
Chris@16
|
9 #define BOOST_ACCUMULATORS_STATISTICS_MAX_HPP_EAN_28_10_2005
|
Chris@16
|
10
|
Chris@16
|
11 #include <limits>
|
Chris@16
|
12 #include <boost/mpl/placeholders.hpp>
|
Chris@16
|
13 #include <boost/accumulators/framework/accumulator_base.hpp>
|
Chris@16
|
14 #include <boost/accumulators/framework/extractor.hpp>
|
Chris@16
|
15 #include <boost/accumulators/framework/parameters/sample.hpp>
|
Chris@16
|
16 #include <boost/accumulators/numeric/functional.hpp>
|
Chris@16
|
17 #include <boost/accumulators/framework/depends_on.hpp>
|
Chris@16
|
18 #include <boost/accumulators/statistics_fwd.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 namespace boost { namespace accumulators
|
Chris@16
|
21 {
|
Chris@16
|
22
|
Chris@16
|
23 namespace impl
|
Chris@16
|
24 {
|
Chris@16
|
25 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
26 // max_impl
|
Chris@16
|
27 template<typename Sample>
|
Chris@16
|
28 struct max_impl
|
Chris@16
|
29 : accumulator_base
|
Chris@16
|
30 {
|
Chris@16
|
31 // for boost::result_of
|
Chris@16
|
32 typedef Sample result_type;
|
Chris@16
|
33
|
Chris@16
|
34 template<typename Args>
|
Chris@16
|
35 max_impl(Args const &args)
|
Chris@16
|
36 : max_(numeric::as_min(args[sample | Sample()]))
|
Chris@16
|
37 {
|
Chris@16
|
38 }
|
Chris@16
|
39
|
Chris@16
|
40 template<typename Args>
|
Chris@16
|
41 void operator ()(Args const &args)
|
Chris@16
|
42 {
|
Chris@16
|
43 numeric::max_assign(this->max_, args[sample]);
|
Chris@16
|
44 }
|
Chris@16
|
45
|
Chris@16
|
46 result_type result(dont_care) const
|
Chris@16
|
47 {
|
Chris@16
|
48 return this->max_;
|
Chris@16
|
49 }
|
Chris@16
|
50
|
Chris@16
|
51 private:
|
Chris@16
|
52 Sample max_;
|
Chris@16
|
53 };
|
Chris@16
|
54
|
Chris@16
|
55 } // namespace impl
|
Chris@16
|
56
|
Chris@16
|
57 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
58 // tag::max
|
Chris@16
|
59 //
|
Chris@16
|
60 namespace tag
|
Chris@16
|
61 {
|
Chris@16
|
62 struct max
|
Chris@16
|
63 : depends_on<>
|
Chris@16
|
64 {
|
Chris@16
|
65 /// INTERNAL ONLY
|
Chris@16
|
66 ///
|
Chris@16
|
67 typedef accumulators::impl::max_impl<mpl::_1> impl;
|
Chris@16
|
68 };
|
Chris@16
|
69 }
|
Chris@16
|
70
|
Chris@16
|
71 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
72 // extract::max
|
Chris@16
|
73 //
|
Chris@16
|
74 namespace extract
|
Chris@16
|
75 {
|
Chris@16
|
76 extractor<tag::max> const max = {};
|
Chris@16
|
77
|
Chris@16
|
78 BOOST_ACCUMULATORS_IGNORE_GLOBAL(max)
|
Chris@16
|
79 }
|
Chris@16
|
80
|
Chris@16
|
81 using extract::max;
|
Chris@16
|
82
|
Chris@16
|
83 }} // namespace boost::accumulators
|
Chris@16
|
84
|
Chris@16
|
85 #endif
|