| 1 | #ifndef ACCU_B_HPP_INCLUDED
|
|---|
| 2 | #define ACCU_B_HPP_INCLUDED
|
|---|
| 3 |
|
|---|
| 4 | #include <boost/parameter/keyword.hpp>
|
|---|
| 5 | #include <boost/mpl/void.hpp>
|
|---|
| 6 | #include <boost/accumulators/framework/extractor.hpp>
|
|---|
| 7 | #include <boost/accumulators/framework/accumulator_base.hpp>
|
|---|
| 8 | #include <boost/accumulators/framework/extractor.hpp>
|
|---|
| 9 | #include <boost/accumulators/numeric/functional.hpp>
|
|---|
| 10 | #include <boost/accumulators/framework/parameters/sample.hpp>
|
|---|
| 11 | #include <boost/accumulators/framework/depends_on.hpp>
|
|---|
| 12 | #include <boost/accumulators/statistics_fwd.hpp>
|
|---|
| 13 | #include <boost/shared_features/temp/accu_a.hpp>
|
|---|
| 14 | namespace boost { namespace accumulators {
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 | namespace impl
|
|---|
| 18 | {
|
|---|
| 19 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 20 | // accu_b_impl
|
|---|
| 21 | template<typename Sample,typename Id0,typename Id1>
|
|---|
| 22 | class accu_b_impl
|
|---|
| 23 | : public accumulator_base
|
|---|
| 24 | {
|
|---|
| 25 | typedef tag::accu_a<Id1> a_type;
|
|---|
| 26 | public:
|
|---|
| 27 | typedef Sample result_type;
|
|---|
| 28 | template<typename Args>
|
|---|
| 29 | accu_b_impl(Args const &args)
|
|---|
| 30 | :x_(
|
|---|
| 31 | extract_result<a_type>(args[accumulator]) //returns garbage
|
|---|
| 32 | )
|
|---|
| 33 | {
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | accu_b_impl(const accu_b_impl& that)
|
|---|
| 37 | :x_(that.x_){}
|
|---|
| 38 |
|
|---|
| 39 | accu_b_impl& operator=(const accu_b_impl& that){
|
|---|
| 40 | if(&that!=this){
|
|---|
| 41 | x_ = that.x_;
|
|---|
| 42 | }
|
|---|
| 43 | return *this;
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 | template<typename Args>
|
|---|
| 48 | void operator ()(Args const &args)
|
|---|
| 49 | {
|
|---|
| 50 | // overrides initialization
|
|---|
| 51 | x_ = extract_result<a_type>(args[accumulator]);
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | result_type result(dont_care) const
|
|---|
| 55 | {
|
|---|
| 56 | return x_;
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | private:
|
|---|
| 60 | result_type x_;
|
|---|
| 61 | };
|
|---|
| 62 |
|
|---|
| 63 | } // namespace impl
|
|---|
| 64 |
|
|---|
| 65 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 66 | // tag::accu_b
|
|---|
| 67 | //
|
|---|
| 68 |
|
|---|
| 69 | namespace tag
|
|---|
| 70 | {
|
|---|
| 71 | template <typename Id0,typename Id1=mpl::void_>
|
|---|
| 72 | struct accu_b
|
|---|
| 73 | : depends_on<tag::accu_a<Id1> >
|
|---|
| 74 | {
|
|---|
| 75 | /// INTERNAL ONLY
|
|---|
| 76 | typedef accumulators::impl::accu_b_impl<mpl::_1,Id0,Id1> impl;
|
|---|
| 77 |
|
|---|
| 78 | };
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | }} // namespace boost::accumulators
|
|---|
| 83 |
|
|---|
| 84 | #endif
|
|---|
| 85 |
|
|---|