PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/accumulators/framework/accumulators/value_accumulator.hpp

http://hadesmem.googlecode.com/
C++ Header | 89 lines | 56 code | 16 blank | 17 comment | 0 complexity | 2b5853786c766a2adc26442b15c4f534 MD5 | raw file
 1///////////////////////////////////////////////////////////////////////////////
 2// value_accumulator.hpp
 3//
 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)
 7
 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
10
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>
16
17namespace boost { namespace accumulators
18{
19
20namespace impl
21{
22
23    //////////////////////////////////////////////////////////////////////////
24    // value_accumulator_impl
25    template<typename ValueType, typename Tag>
26    struct value_accumulator_impl
27      : accumulator_base
28    {
29        typedef ValueType result_type;
30
31        template<typename Args>
32        value_accumulator_impl(Args const &args)
33          : val(args[parameter::keyword<Tag>::get()])
34        {
35        }
36
37        result_type result(dont_care) const
38        {
39            return this->val;
40        }
41
42    private:
43        ValueType val;
44    };
45
46} // namespace impl
47
48namespace tag
49{
50    //////////////////////////////////////////////////////////////////////////
51    // value_tag
52    template<typename Tag>
53    struct value_tag
54    {
55    };
56
57    //////////////////////////////////////////////////////////////////////////
58    // value
59    template<typename ValueType, typename Tag>
60    struct value
61      : depends_on<>
62    {
63        /// INTERNAL ONLY
64        ///
65        typedef mpl::always<accumulators::impl::value_accumulator_impl<ValueType, Tag> > impl;
66    };
67}
68
69namespace extract
70{
71    BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value, (typename)(typename))
72    BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value_tag, (typename))
73}
74
75using extract::value;
76using extract::value_tag;
77
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.
81template<typename ValueType, typename Tag>
82struct feature_of<tag::value<ValueType, Tag> >
83  : feature_of<tag::value_tag<Tag> >
84{
85};
86
87}} // namespace boost::accumulators
88
89#endif