Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / accumulators / framework / accumulators / external_accumulator.hpp @ 2486

History | View | Annotate | Download (3.5 kB)

1 2486 sjacqu01
///////////////////////////////////////////////////////////////////////////////
2 2486 sjacqu01
// external_accumulator.hpp
3 2486 sjacqu01
//
4 2486 sjacqu01
//  Copyright 2005 Eric Niebler. Distributed under the Boost
5 2486 sjacqu01
//  Software License, Version 1.0. (See accompanying file
6 2486 sjacqu01
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 2486 sjacqu01
8 2486 sjacqu01
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_EXTERNAL_ACCUMULATOR_HPP_EAN_01_12_2005
9 2486 sjacqu01
#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_EXTERNAL_ACCUMULATOR_HPP_EAN_01_12_2005
10 2486 sjacqu01
11 2486 sjacqu01
#include <boost/mpl/placeholders.hpp>
12 2486 sjacqu01
#include <boost/parameter/keyword.hpp>
13 2486 sjacqu01
#include <boost/accumulators/framework/extractor.hpp>
14 2486 sjacqu01
#include <boost/accumulators/framework/depends_on.hpp> // for feature_tag
15 2486 sjacqu01
#include <boost/accumulators/framework/accumulator_base.hpp>
16 2486 sjacqu01
#include <boost/accumulators/framework/accumulators/reference_accumulator.hpp>
17 2486 sjacqu01
18 2486 sjacqu01
namespace boost { namespace accumulators { namespace impl
19 2486 sjacqu01
{
20 2486 sjacqu01
21 2486 sjacqu01
    //////////////////////////////////////////////////////////////////////////
22 2486 sjacqu01
    // external_impl
23 2486 sjacqu01
    /// INTERNAL ONLY
24 2486 sjacqu01
    ///
25 2486 sjacqu01
    template<typename Accumulator, typename Tag>
26 2486 sjacqu01
    struct external_impl
27 2486 sjacqu01
      : accumulator_base
28 2486 sjacqu01
    {
29 2486 sjacqu01
        typedef typename Accumulator::result_type result_type;
30 2486 sjacqu01
        typedef typename detail::feature_tag<Accumulator>::type feature_tag;
31 2486 sjacqu01
32 2486 sjacqu01
        external_impl(dont_care) {}
33 2486 sjacqu01
34 2486 sjacqu01
        template<typename Args>
35 2486 sjacqu01
        result_type result(Args const &args) const
36 2486 sjacqu01
        {
37 2486 sjacqu01
            return this->extract_(args, args[parameter::keyword<Tag>::get() | 0]);
38 2486 sjacqu01
        }
39 2486 sjacqu01
40 2486 sjacqu01
    private:
41 2486 sjacqu01
42 2486 sjacqu01
        template<typename Args>
43 2486 sjacqu01
        static result_type extract_(Args const &args, int)
44 2486 sjacqu01
        {
45 2486 sjacqu01
            // No named parameter passed to the extractor. Maybe the external
46 2486 sjacqu01
            // feature is held by reference<>.
47 2486 sjacqu01
            extractor<feature_tag> extract;
48 2486 sjacqu01
            return extract(accumulators::reference_tag<Tag>(args));
49 2486 sjacqu01
        }
50 2486 sjacqu01
51 2486 sjacqu01
        template<typename Args, typename AccumulatorSet>
52 2486 sjacqu01
        static result_type extract_(Args const &, AccumulatorSet const &acc)
53 2486 sjacqu01
        {
54 2486 sjacqu01
            // OK, a named parameter for this external feature was passed to the
55 2486 sjacqu01
            // extractor, so use that.
56 2486 sjacqu01
            extractor<feature_tag> extract;
57 2486 sjacqu01
            return extract(acc);
58 2486 sjacqu01
        }
59 2486 sjacqu01
    };
60 2486 sjacqu01
61 2486 sjacqu01
} // namespace impl
62 2486 sjacqu01
63 2486 sjacqu01
namespace tag
64 2486 sjacqu01
{
65 2486 sjacqu01
    //////////////////////////////////////////////////////////////////////////
66 2486 sjacqu01
    // external
67 2486 sjacqu01
    template<typename Feature, typename Tag, typename AccumulatorSet>
68 2486 sjacqu01
    struct external
69 2486 sjacqu01
      : depends_on<reference<AccumulatorSet, Tag> >
70 2486 sjacqu01
    {
71 2486 sjacqu01
        typedef
72 2486 sjacqu01
            accumulators::impl::external_impl<
73 2486 sjacqu01
                detail::to_accumulator<Feature, mpl::_1, mpl::_2>
74 2486 sjacqu01
              , Tag
75 2486 sjacqu01
            >
76 2486 sjacqu01
        impl;
77 2486 sjacqu01
    };
78 2486 sjacqu01
79 2486 sjacqu01
    template<typename Feature, typename Tag>
80 2486 sjacqu01
    struct external<Feature, Tag, void>
81 2486 sjacqu01
      : depends_on<>
82 2486 sjacqu01
    {
83 2486 sjacqu01
        typedef
84 2486 sjacqu01
            accumulators::impl::external_impl<
85 2486 sjacqu01
                detail::to_accumulator<Feature, mpl::_1, mpl::_2>
86 2486 sjacqu01
              , Tag
87 2486 sjacqu01
            >
88 2486 sjacqu01
        impl;
89 2486 sjacqu01
    };
90 2486 sjacqu01
}
91 2486 sjacqu01
92 2486 sjacqu01
// for the purposes of feature-based dependency resolution,
93 2486 sjacqu01
// external_accumulator<Feature, Tag> provides the same feature as Feature
94 2486 sjacqu01
template<typename Feature, typename Tag, typename AccumulatorSet>
95 2486 sjacqu01
struct feature_of<tag::external<Feature, Tag, AccumulatorSet> >
96 2486 sjacqu01
  : feature_of<Feature>
97 2486 sjacqu01
{
98 2486 sjacqu01
};
99 2486 sjacqu01
100 2486 sjacqu01
// Note: Usually, the extractor is pulled into the accumulators namespace with
101 2486 sjacqu01
// a using directive, not the tag. But the external<> feature doesn't have an
102 2486 sjacqu01
// extractor, so we can put the external tag in the accumulators namespace
103 2486 sjacqu01
// without fear of a name conflict.
104 2486 sjacqu01
using tag::external;
105 2486 sjacqu01
106 2486 sjacqu01
}} // namespace boost::accumulators
107 2486 sjacqu01
108 2486 sjacqu01
#endif