1 ///////////////////////////////////////////////////////////////////////////////
2 // value_accumulator.hpp
4 // Copyright 2005 Eric Niebler, Daniel Egloff. Distributed under the Boost
5 // Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006
9 #define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006
11 #include <boost/mpl/always.hpp>
12 #include <boost/parameter/keyword.hpp>
13 #include <boost/accumulators/framework/depends_on.hpp> // for feature_tag
14 #include <boost/accumulators/framework/accumulator_base.hpp>
15 #include <boost/accumulators/framework/extractor.hpp>
17 namespace boost { namespace accumulators
23 //////////////////////////////////////////////////////////////////////////
24 // value_accumulator_impl
25 template<typename ValueType, typename Tag>
26 struct value_accumulator_impl
29 typedef ValueType result_type;
31 template<typename Args>
32 value_accumulator_impl(Args const &args)
33 : val(args[parameter::keyword<Tag>::instance])
37 result_type result(dont_care) const
50 //////////////////////////////////////////////////////////////////////////
52 template<typename Tag>
57 //////////////////////////////////////////////////////////////////////////
59 template<typename ValueType, typename Tag>
65 typedef mpl::always<accumulators::impl::value_accumulator_impl<ValueType, Tag> > impl;
71 BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value, (typename)(typename))
72 BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value_tag, (typename))
76 using extract::value_tag;
78 // Map all value<V,T> features to value_tag<T> so
79 // that values can be extracted using value_tag<T>
80 // without specifying the value type.
81 template<typename ValueType, typename Tag>
82 struct feature_of<tag::value<ValueType, Tag> >
83 : feature_of<tag::value_tag<Tag> >
87 }} // namespace boost::accumulators