Ticket #2833: accu_a.hpp

File accu_a.hpp, 1.9 KB (added by anonymous, 14 years ago)
Line 
1#ifndef ACCU_A_INCLUDED
2#define ACCU_A_INCLUDED
3#include <boost/parameter/keyword.hpp>
4#include <boost/mpl/void.hpp>
5#include <boost/accumulators/framework/accumulator_base.hpp>
6#include <boost/accumulators/framework/extractor.hpp>
7#include <boost/accumulators/framework/depends_on.hpp>
8
9namespace boost { namespace accumulators {
10
11namespace tag{
12 struct kwd_value_;
13}
14namespace{
15 template<typename Id>
16 struct kwd{
17 static ::boost::parameter::keyword<tag::kwd_value_>& value;
18 };
19 template<typename Id>
20 ::boost::parameter::keyword<tag::kwd_value_>&
21 kwd<Id>::value = ::boost::parameter::keyword<tag::kwd_value_>::get();
22
23}
24
25namespace impl
26{
27 ////////////////////////////////////////////////////////////////////////////
28 // accu_a_impl
29 template<typename Sample,typename Id>
30 class accu_a_impl
31 : public accumulator_base
32 {
33 public:
34 typedef Sample result_type;
35 template<typename Args>
36 accu_a_impl(Args const &args)
37 :x_(
38 args[kwd<Id>::value]
39 )
40 {
41 }
42
43 accu_a_impl(const accu_a_impl& that)
44 :x_(that.x_){}
45
46 accu_a_impl& operator=(const accu_a_impl& that){
47 if(&that!=this){
48 x_ = that.x_;
49 }
50 return *this;
51 }
52
53
54 template<typename Args>
55 void operator ()(Args const &args)
56 {
57
58 }
59
60 result_type result(dont_care) const
61 {
62 return x_;
63 }
64
65 private:
66 result_type x_;
67 };
68
69} // namespace impl
70
71///////////////////////////////////////////////////////////////////////////////
72// tag::accu_a
73//
74
75namespace tag
76{
77 template <typename Id = mpl::void_>
78 struct accu_a
79 : depends_on<>
80 {
81 /// INTERNAL ONLY
82 typedef accumulators::impl::accu_a_impl<mpl::_1,Id> impl;
83
84 };
85}
86
87
88}} // namespace boost::accumulators
89
90#endif