Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////////
// accumulator_base.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_BASE_HPP_EAN_28_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_BASE_HPP_EAN_28_10_2005
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/joint_view.hpp>
#include <boost/mpl/single_view.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/mpl/empty_sequence.hpp>
#include <boost/accumulators/framework/accumulator_concept.hpp>
namespace boost { namespace accumulators
{
namespace detail
{
typedef void void_;
}
///////////////////////////////////////////////////////////////////////////////
// dont_care
//
struct dont_care
{
template<typename Args>
dont_care(Args const &)
{
}
};
///////////////////////////////////////////////////////////////////////////////
// accumulator_base
//
struct accumulator_base
{
// hidden if defined in derived classes
detail::void_ operator ()(dont_care)
{
}
typedef mpl::false_ is_droppable;
detail::void_ add_ref(dont_care)
{
}
detail::void_ drop(dont_care)
{
}
detail::void_ on_drop(dont_care)
{
}
};
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,29 @@
///////////////////////////////////////////////////////////////////////////////
// accumulator_concept.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_CONCEPT_HPP_EAN_28_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_CONCEPT_HPP_EAN_28_10_2005
#include <boost/concept_check.hpp>
namespace boost { namespace accumulators
{
template<typename Stat>
struct accumulator_concept
{
void constraints()
{
// TODO: define the stat concept
}
Stat stat;
};
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,401 @@
///////////////////////////////////////////////////////////////////////////////
// accumulator_set.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_SET_HPP_EAN_28_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_SET_HPP_EAN_28_10_2005
#include <boost/version.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/protect.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/parameter/parameters.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/accumulators/framework/depends_on.hpp>
#include <boost/accumulators/framework/accumulator_concept.hpp>
#include <boost/accumulators/framework/parameters/accumulator.hpp>
#include <boost/accumulators/framework/parameters/sample.hpp>
#include <boost/accumulators/framework/accumulators/external_accumulator.hpp>
#include <boost/accumulators/framework/accumulators/droppable_accumulator.hpp>
#include <boost/fusion/include/any.hpp>
#include <boost/fusion/include/find_if.hpp>
#include <boost/fusion/include/for_each.hpp>
#include <boost/fusion/include/filter_view.hpp>
namespace boost { namespace accumulators
{
namespace detail
{
///////////////////////////////////////////////////////////////////////////////
// accumulator_visitor
// wrap a boost::parameter argument pack in a Fusion extractor object
template<typename Args>
struct accumulator_visitor
{
explicit accumulator_visitor(Args const &a)
: args(a)
{
}
template<typename Accumulator>
void operator ()(Accumulator &accumulator) const
{
accumulator(this->args);
}
private:
accumulator_visitor &operator =(accumulator_visitor const &);
Args const &args;
};
template<typename Args>
inline accumulator_visitor<Args> const make_accumulator_visitor(Args const &args)
{
return accumulator_visitor<Args>(args);
}
typedef
parameter::parameters<
parameter::required<tag::accumulator>
, parameter::optional<tag::sample>
// ... and others which are not specified here...
>
accumulator_params;
///////////////////////////////////////////////////////////////////////////////
// accumulator_set_base
struct accumulator_set_base
{
};
///////////////////////////////////////////////////////////////////////////////
// is_accumulator_set
template<typename T>
struct is_accumulator_set
: is_base_and_derived<accumulator_set_base, T>
{
};
} // namespace detail
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4355) // warning C4355: 'this' : used in base member initializer list
#endif
///////////////////////////////////////////////////////////////////////////////
/// \brief A set of accumulators.
///
/// accumulator_set resolves the dependencies between features and ensures that
/// the accumulators in the set are updated in the proper order.
///
/// acccumulator_set provides a general mechanism to visit the accumulators
/// in the set in order, with or without a filter. You can also fetch a reference
/// to an accumulator that corresponds to a feature.
///
template<typename Sample, typename Features, typename Weight>
struct accumulator_set
: detail::accumulator_set_base
{
typedef Sample sample_type; ///< The type of the samples that will be accumulated
typedef Features features_type; ///< An MPL sequence of the features that should be accumulated.
typedef Weight weight_type; ///< The type of the weight parameter. Must be a scalar. Defaults to void.
/// INTERNAL ONLY
///
typedef
typename detail::make_accumulator_tuple<
Features
, Sample
, Weight
>::type
accumulators_mpl_vector;
// generate a fusion::list of accumulators
/// INTERNAL ONLY
///
typedef
typename detail::meta::make_acc_list<
accumulators_mpl_vector
>::type
accumulators_type;
/// INTERNAL ONLY
///
//BOOST_MPL_ASSERT((mpl::is_sequence<accumulators_type>));
///////////////////////////////////////////////////////////////////////////////
/// default-construct all contained accumulators
accumulator_set()
: accumulators(
detail::make_acc_list(
accumulators_mpl_vector()
, detail::accumulator_params()(*this)
)
)
{
// Add-ref the Features that the user has specified
this->template visit_if<detail::contains_feature_of_<Features> >(
detail::make_add_ref_visitor(detail::accumulator_params()(*this))
);
}
/// \overload
///
/// \param a1 Optional named parameter to be passed to all the accumulators
template<typename A1>
explicit accumulator_set(A1 const &a1)
: accumulators(
detail::make_acc_list(
accumulators_mpl_vector()
, detail::accumulator_params()(*this, a1)
)
)
{
// Add-ref the Features that the user has specified
this->template visit_if<detail::contains_feature_of_<Features> >(
detail::make_add_ref_visitor(detail::accumulator_params()(*this))
);
}
// ... other overloads generated by Boost.Preprocessor:
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_ACCUMULATOR_SET_CTOR(z, n, _) \
template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
accumulator_set(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a)) \
: accumulators( \
detail::make_acc_list( \
accumulators_mpl_vector() \
, detail::accumulator_params()( \
*this BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
) \
) \
) \
{ \
/* Add-ref the Features that the user has specified */ \
this->template visit_if<detail::contains_feature_of_<Features> >( \
detail::make_add_ref_visitor(detail::accumulator_params()(*this)) \
); \
}
/// INTERNAL ONLY
///
BOOST_PP_REPEAT_FROM_TO(
2
, BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
, BOOST_ACCUMULATORS_ACCUMULATOR_SET_CTOR
, _
)
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
/// \overload
///
template<typename A1, typename A2, ...>
accumulator_set(A1 const &a1, A2 const &a2, ...);
#endif
// ... other overloads generated by Boost.Preprocessor below ...
///////////////////////////////////////////////////////////////////////////////
/// Visitation
/// \param func UnaryFunction which is invoked with each accumulator in turn.
template<typename UnaryFunction>
void visit(UnaryFunction const &func)
{
fusion::for_each(this->accumulators, func);
}
///////////////////////////////////////////////////////////////////////////////
/// Conditional visitation
/// \param func UnaryFunction which is invoked with each accumulator in turn,
/// provided the accumulator satisfies the MPL predicate FilterPred.
template<typename FilterPred, typename UnaryFunction>
void visit_if(UnaryFunction const &func)
{
fusion::filter_view<accumulators_type, FilterPred> filtered_accs(this->accumulators);
fusion::for_each(filtered_accs, func);
}
///////////////////////////////////////////////////////////////////////////////
/// The return type of the operator() overloads is void.
typedef void result_type;
///////////////////////////////////////////////////////////////////////////////
/// Accumulation
/// \param a1 Optional named parameter to be passed to all the accumulators
void operator ()()
{
this->visit(
detail::make_accumulator_visitor(
detail::accumulator_params()(*this)
)
);
}
template<typename A1>
void operator ()(A1 const &a1)
{
this->visit(
detail::make_accumulator_visitor(
detail::accumulator_params()(*this, a1)
)
);
}
// ... other overloads generated by Boost.Preprocessor:
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_ACCUMULATOR_SET_FUN_OP(z, n, _) \
template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
void operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a)) \
{ \
this->visit( \
detail::make_accumulator_visitor( \
detail::accumulator_params()( \
*this BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
) \
) \
); \
}
/// INTERNAL ONLY
///
BOOST_PP_REPEAT_FROM_TO(
2
, BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
, BOOST_ACCUMULATORS_ACCUMULATOR_SET_FUN_OP
, _
)
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
/// \overload
///
template<typename A1, typename A2, ...>
void operator ()(A1 const &a1, A2 const &a2, ...);
#endif
///////////////////////////////////////////////////////////////////////////////
/// Extraction
template<typename Feature>
struct apply
: fusion::result_of::value_of<
typename fusion::result_of::find_if<
accumulators_type
, detail::matches_feature<Feature>
>::type
>
{
};
///////////////////////////////////////////////////////////////////////////////
/// Extraction
template<typename Feature>
typename apply<Feature>::type &extract()
{
return *fusion::find_if<detail::matches_feature<Feature> >(this->accumulators);
}
/// \overload
template<typename Feature>
typename apply<Feature>::type const &extract() const
{
return *fusion::find_if<detail::matches_feature<Feature> >(this->accumulators);
}
///////////////////////////////////////////////////////////////////////////////
/// Drop
template<typename Feature>
void drop()
{
// You can only drop the features that you have specified explicitly
typedef typename apply<Feature>::type the_accumulator;
BOOST_MPL_ASSERT((detail::contains_feature_of<Features, the_accumulator>));
typedef
typename feature_of<typename as_feature<Feature>::type>::type
the_feature;
(*fusion::find_if<detail::matches_feature<Feature> >(this->accumulators))
.drop(detail::accumulator_params()(*this));
// Also drop accumulators that this feature depends on
typedef typename the_feature::dependencies dependencies;
this->template visit_if<detail::contains_feature_of_<dependencies> >(
detail::make_drop_visitor(detail::accumulator_params()(*this))
);
}
private:
accumulators_type accumulators;
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif
///////////////////////////////////////////////////////////////////////////////
// find_accumulator
// find an accumulator in an accumulator_set corresponding to a feature
template<typename Feature, typename AccumulatorSet>
typename mpl::apply<AccumulatorSet, Feature>::type &
find_accumulator(AccumulatorSet &acc BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(AccumulatorSet))
{
return acc.template extract<Feature>();
}
/// \overload
template<typename Feature, typename AccumulatorSet>
typename mpl::apply<AccumulatorSet, Feature>::type const &
find_accumulator(AccumulatorSet const &acc)
{
return acc.template extract<Feature>();
}
///////////////////////////////////////////////////////////////////////////////
// extract_result
// extract a result from an accumulator set
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_EXTRACT_RESULT_FUN(z, n, _) \
template< \
typename Feature \
, typename AccumulatorSet \
BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \
> \
typename mpl::apply<AccumulatorSet, Feature>::type::result_type \
extract_result( \
AccumulatorSet const &acc \
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
) \
{ \
return find_accumulator<Feature>(acc).result( \
detail::accumulator_params()( \
acc \
BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
) \
); \
}
BOOST_PP_REPEAT(
BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
, BOOST_ACCUMULATORS_EXTRACT_RESULT_FUN
, _
)
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,317 @@
///////////////////////////////////////////////////////////////////////////////
// droppable_accumulator.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_DROPPABLE_ACCUMULATOR_HPP_EAN_13_12_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_DROPPABLE_ACCUMULATOR_HPP_EAN_13_12_2005
#include <new>
#include <boost/assert.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/aligned_storage.hpp>
#include <boost/accumulators/framework/depends_on.hpp> // for feature_of
#include <boost/accumulators/framework/parameters/accumulator.hpp> // for accumulator
namespace boost { namespace accumulators
{
template<typename Accumulator>
struct droppable_accumulator;
namespace detail
{
///////////////////////////////////////////////////////////////////////////////
// add_ref_visitor
// a fusion function object for add_ref'ing accumulators
template<typename Args>
struct add_ref_visitor
{
explicit add_ref_visitor(Args const &args)
: args_(args)
{
}
template<typename Accumulator>
void operator ()(Accumulator &acc) const
{
typedef typename Accumulator::feature_tag::dependencies dependencies;
acc.add_ref(this->args_);
// Also add_ref accumulators that this feature depends on
this->args_[accumulator].template
visit_if<detail::contains_feature_of_<dependencies> >(
*this
);
}
private:
add_ref_visitor &operator =(add_ref_visitor const &);
Args const &args_;
};
template<typename Args>
add_ref_visitor<Args> make_add_ref_visitor(Args const &args)
{
return add_ref_visitor<Args>(args);
}
///////////////////////////////////////////////////////////////////////////////
// drop_visitor
// a fusion function object for dropping accumulators
template<typename Args>
struct drop_visitor
{
explicit drop_visitor(Args const &args)
: args_(args)
{
}
template<typename Accumulator>
void operator ()(Accumulator &acc) const
{
if(typename Accumulator::is_droppable())
{
typedef typename Accumulator::feature_tag::dependencies dependencies;
acc.drop(this->args_);
// Also drop accumulators that this feature depends on
this->args_[accumulator].template
visit_if<detail::contains_feature_of_<dependencies> >(
*this
);
}
}
private:
drop_visitor &operator =(drop_visitor const &);
Args const &args_;
};
template<typename Args>
drop_visitor<Args> make_drop_visitor(Args const &args)
{
return drop_visitor<Args>(args);
}
}
//////////////////////////////////////////////////////////////////////////
// droppable_accumulator_base
template<typename Accumulator>
struct droppable_accumulator_base
: Accumulator
{
typedef droppable_accumulator_base base;
typedef mpl::true_ is_droppable;
typedef typename Accumulator::result_type result_type;
template<typename Args>
droppable_accumulator_base(Args const &args)
: Accumulator(args)
, ref_count_(0)
{
}
template<typename Args>
void operator ()(Args const &args)
{
if(!this->is_dropped())
{
this->Accumulator::operator ()(args);
}
}
template<typename Args>
void add_ref(Args const &)
{
++this->ref_count_;
}
template<typename Args>
void drop(Args const &args)
{
BOOST_ASSERT(0 < this->ref_count_);
if(1 == this->ref_count_)
{
static_cast<droppable_accumulator<Accumulator> *>(this)->on_drop(args);
}
--this->ref_count_;
}
bool is_dropped() const
{
return 0 == this->ref_count_;
}
private:
int ref_count_;
};
//////////////////////////////////////////////////////////////////////////
// droppable_accumulator
// this can be specialized for any type that needs special handling
template<typename Accumulator>
struct droppable_accumulator
: droppable_accumulator_base<Accumulator>
{
template<typename Args>
droppable_accumulator(Args const &args)
: droppable_accumulator::base(args)
{
}
};
//////////////////////////////////////////////////////////////////////////
// with_cached_result
template<typename Accumulator>
struct with_cached_result
: Accumulator
{
typedef typename Accumulator::result_type result_type;
template<typename Args>
with_cached_result(Args const &args)
: Accumulator(args)
, cache()
{
}
with_cached_result(with_cached_result const &that)
: Accumulator(*static_cast<Accumulator const *>(&that))
, cache()
{
if(that.has_result())
{
this->set(that.get());
}
}
~with_cached_result()
{
// Since this is a base class of droppable_accumulator_base,
// this destructor is called before any of droppable_accumulator_base's
// members get cleaned up, including is_dropped, so the following
// call to has_result() is valid.
if(this->has_result())
{
this->get().~result_type();
}
}
template<typename Args>
void on_drop(Args const &args)
{
// cache the result at the point this calcuation was dropped
BOOST_ASSERT(!this->has_result());
this->set(this->Accumulator::result(args));
}
template<typename Args>
result_type result(Args const &args) const
{
return this->has_result() ? this->get() : this->Accumulator::result(args);
}
private:
with_cached_result &operator =(with_cached_result const &);
void set(result_type const &r)
{
::new(this->cache.address()) result_type(r);
}
result_type const &get() const
{
return *static_cast<result_type const *>(this->cache.address());
}
bool has_result() const
{
typedef with_cached_result<Accumulator> this_type;
typedef droppable_accumulator_base<this_type> derived_type;
return static_cast<derived_type const *>(this)->is_dropped();
}
aligned_storage<sizeof(result_type)> cache;
};
namespace tag
{
template<typename Feature>
struct as_droppable
{
typedef droppable<Feature> type;
};
template<typename Feature>
struct as_droppable<droppable<Feature> >
{
typedef droppable<Feature> type;
};
//////////////////////////////////////////////////////////////////////////
// droppable
template<typename Feature>
struct droppable
: as_feature<Feature>::type
{
typedef typename as_feature<Feature>::type feature_type;
typedef typename feature_type::dependencies tmp_dependencies_;
typedef
typename mpl::transform<
typename feature_type::dependencies
, as_droppable<mpl::_1>
>::type
dependencies;
struct impl
{
template<typename Sample, typename Weight>
struct apply
{
typedef
droppable_accumulator<
typename mpl::apply2<typename feature_type::impl, Sample, Weight>::type
>
type;
};
};
};
}
// make droppable<tag::feature(modifier)> work
template<typename Feature>
struct as_feature<tag::droppable<Feature> >
{
typedef tag::droppable<typename as_feature<Feature>::type> type;
};
// make droppable<tag::mean> work with non-void weights (should become
// droppable<tag::weighted_mean>
template<typename Feature>
struct as_weighted_feature<tag::droppable<Feature> >
{
typedef tag::droppable<typename as_weighted_feature<Feature>::type> type;
};
// for the purposes of feature-based dependency resolution,
// droppable<Foo> provides the same feature as Foo
template<typename Feature>
struct feature_of<tag::droppable<Feature> >
: feature_of<Feature>
{
};
// Note: Usually, the extractor is pulled into the accumulators namespace with
// a using directive, not the tag. But the droppable<> feature doesn't have an
// extractor, so we can put the droppable tag in the accumulators namespace
// without fear of a name conflict.
using tag::droppable;
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,108 @@
///////////////////////////////////////////////////////////////////////////////
// external_accumulator.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_EXTERNAL_ACCUMULATOR_HPP_EAN_01_12_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_EXTERNAL_ACCUMULATOR_HPP_EAN_01_12_2005
#include <boost/mpl/placeholders.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/accumulators/framework/extractor.hpp>
#include <boost/accumulators/framework/depends_on.hpp> // for feature_tag
#include <boost/accumulators/framework/accumulator_base.hpp>
#include <boost/accumulators/framework/accumulators/reference_accumulator.hpp>
namespace boost { namespace accumulators { namespace impl
{
//////////////////////////////////////////////////////////////////////////
// external_impl
/// INTERNAL ONLY
///
template<typename Accumulator, typename Tag>
struct external_impl
: accumulator_base
{
typedef typename Accumulator::result_type result_type;
typedef typename detail::feature_tag<Accumulator>::type feature_tag;
external_impl(dont_care) {}
template<typename Args>
result_type result(Args const &args) const
{
return this->extract_(args, args[parameter::keyword<Tag>::get() | 0]);
}
private:
template<typename Args>
static result_type extract_(Args const &args, int)
{
// No named parameter passed to the extractor. Maybe the external
// feature is held by reference<>.
extractor<feature_tag> extract;
return extract(accumulators::reference_tag<Tag>(args));
}
template<typename Args, typename AccumulatorSet>
static result_type extract_(Args const &, AccumulatorSet const &acc)
{
// OK, a named parameter for this external feature was passed to the
// extractor, so use that.
extractor<feature_tag> extract;
return extract(acc);
}
};
} // namespace impl
namespace tag
{
//////////////////////////////////////////////////////////////////////////
// external
template<typename Feature, typename Tag, typename AccumulatorSet>
struct external
: depends_on<reference<AccumulatorSet, Tag> >
{
typedef
accumulators::impl::external_impl<
detail::to_accumulator<Feature, mpl::_1, mpl::_2>
, Tag
>
impl;
};
template<typename Feature, typename Tag>
struct external<Feature, Tag, void>
: depends_on<>
{
typedef
accumulators::impl::external_impl<
detail::to_accumulator<Feature, mpl::_1, mpl::_2>
, Tag
>
impl;
};
}
// for the purposes of feature-based dependency resolution,
// external_accumulator<Feature, Tag> provides the same feature as Feature
template<typename Feature, typename Tag, typename AccumulatorSet>
struct feature_of<tag::external<Feature, Tag, AccumulatorSet> >
: feature_of<Feature>
{
};
// Note: Usually, the extractor is pulled into the accumulators namespace with
// a using directive, not the tag. But the external<> feature doesn't have an
// extractor, so we can put the external tag in the accumulators namespace
// without fear of a name conflict.
using tag::external;
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,89 @@
///////////////////////////////////////////////////////////////////////////////
// reference_accumulator.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_REFERENCE_ACCUMULATOR_HPP_EAN_03_23_2006
#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_REFERENCE_ACCUMULATOR_HPP_EAN_03_23_2006
#include <boost/ref.hpp>
#include <boost/mpl/always.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/accumulators/framework/depends_on.hpp> // for feature_tag
#include <boost/accumulators/framework/accumulator_base.hpp>
#include <boost/accumulators/framework/extractor.hpp>
namespace boost { namespace accumulators
{
namespace impl
{
//////////////////////////////////////////////////////////////////////////
// reference_accumulator_impl
//
template<typename Referent, typename Tag>
struct reference_accumulator_impl
: accumulator_base
{
typedef Referent &result_type;
template<typename Args>
reference_accumulator_impl(Args const &args)
: ref(args[parameter::keyword<Tag>::get()])
{
}
result_type result(dont_care) const
{
return this->ref;
}
private:
reference_wrapper<Referent> ref;
};
} // namespace impl
namespace tag
{
//////////////////////////////////////////////////////////////////////////
// reference_tag
template<typename Tag>
struct reference_tag
{
};
//////////////////////////////////////////////////////////////////////////
// reference
template<typename Referent, typename Tag>
struct reference
: depends_on<>
{
/// INTERNAL ONLY
///
typedef mpl::always<accumulators::impl::reference_accumulator_impl<Referent, Tag> > impl;
};
}
namespace extract
{
BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, reference, (typename)(typename))
BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, reference_tag, (typename))
}
using extract::reference;
using extract::reference_tag;
// Map all reference<V,T> features to reference_tag<T> so
// that references can be extracted using reference_tag<T>
// without specifying the referent type.
template<typename ValueType, typename Tag>
struct feature_of<tag::reference<ValueType, Tag> >
: feature_of<tag::reference_tag<Tag> >
{
};
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,89 @@
///////////////////////////////////////////////////////////////////////////////
// value_accumulator.hpp
//
// Copyright 2005 Eric Niebler, Daniel Egloff. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006
#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006
#include <boost/mpl/always.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/accumulators/framework/depends_on.hpp> // for feature_tag
#include <boost/accumulators/framework/accumulator_base.hpp>
#include <boost/accumulators/framework/extractor.hpp>
namespace boost { namespace accumulators
{
namespace impl
{
//////////////////////////////////////////////////////////////////////////
// value_accumulator_impl
template<typename ValueType, typename Tag>
struct value_accumulator_impl
: accumulator_base
{
typedef ValueType result_type;
template<typename Args>
value_accumulator_impl(Args const &args)
: val(args[parameter::keyword<Tag>::get()])
{
}
result_type result(dont_care) const
{
return this->val;
}
private:
ValueType val;
};
} // namespace impl
namespace tag
{
//////////////////////////////////////////////////////////////////////////
// value_tag
template<typename Tag>
struct value_tag
{
};
//////////////////////////////////////////////////////////////////////////
// value
template<typename ValueType, typename Tag>
struct value
: depends_on<>
{
/// INTERNAL ONLY
///
typedef mpl::always<accumulators::impl::value_accumulator_impl<ValueType, Tag> > impl;
};
}
namespace extract
{
BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value, (typename)(typename))
BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value_tag, (typename))
}
using extract::value;
using extract::value_tag;
// Map all value<V,T> features to value_tag<T> so
// that values can be extracted using value_tag<T>
// without specifying the value type.
template<typename ValueType, typename Tag>
struct feature_of<tag::value<ValueType, Tag> >
: feature_of<tag::value_tag<Tag> >
{
};
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,411 @@
///////////////////////////////////////////////////////////////////////////////
// depends_on.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_DEPENDS_ON_HPP_EAN_28_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_DEPENDS_ON_HPP_EAN_28_10_2005
#include <boost/version.hpp>
#include <boost/mpl/end.hpp>
#include <boost/mpl/map.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/sort.hpp>
#include <boost/mpl/insert.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/remove.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/inherit.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/mpl/transform.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/insert_range.hpp>
#include <boost/mpl/transform_view.hpp>
#include <boost/mpl/inherit_linearly.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/fusion/include/next.hpp>
#include <boost/fusion/include/equal_to.hpp>
#include <boost/fusion/include/value_of.hpp>
#include <boost/fusion/include/mpl.hpp>
#include <boost/fusion/include/end.hpp>
#include <boost/fusion/include/begin.hpp>
#include <boost/fusion/include/cons.hpp>
namespace boost { namespace accumulators
{
///////////////////////////////////////////////////////////////////////////
// as_feature
template<typename Feature>
struct as_feature
{
typedef Feature type;
};
///////////////////////////////////////////////////////////////////////////
// weighted_feature
template<typename Feature>
struct as_weighted_feature
{
typedef Feature type;
};
///////////////////////////////////////////////////////////////////////////
// feature_of
template<typename Feature>
struct feature_of
{
typedef Feature type;
};
namespace detail
{
///////////////////////////////////////////////////////////////////////////
// feature_tag
template<typename Accumulator>
struct feature_tag
{
typedef typename Accumulator::feature_tag type;
};
template<typename Feature>
struct undroppable
{
typedef Feature type;
};
template<typename Feature>
struct undroppable<tag::droppable<Feature> >
{
typedef Feature type;
};
// For the purpose of determining whether one feature depends on another,
// disregard whether the feature is droppable or not.
template<typename A, typename B>
struct is_dependent_on
: is_base_and_derived<
typename undroppable<B>::type
, typename undroppable<A>::type
>
{};
template<typename Features>
struct depends_on_base
: mpl::inherit_linearly<
typename mpl::sort<Features, is_dependent_on<mpl::_1, mpl::_2> >::type
// Don't inherit multiply from a feature
, mpl::if_<
is_dependent_on<mpl::_1, mpl::_2>
, mpl::_1
, mpl::inherit<mpl::_1, mpl::_2>
>
>::type
{
};
}
///////////////////////////////////////////////////////////////////////////
/// depends_on
template<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature)>
struct depends_on
: detail::depends_on_base<
typename mpl::transform<
mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, Feature)>
, as_feature<mpl::_1>
>::type
>
{
typedef mpl::false_ is_weight_accumulator;
typedef
typename mpl::transform<
mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, Feature)>
, as_feature<mpl::_1>
>::type
dependencies;
};
namespace detail
{
template<typename Feature>
struct matches_feature
{
template<typename Accumulator>
struct apply
: is_same<
typename feature_of<typename as_feature<Feature>::type>::type
, typename feature_of<typename as_feature<typename feature_tag<Accumulator>::type>::type>::type
>
{};
};
template<typename Features, typename Accumulator>
struct contains_feature_of
{
typedef
mpl::transform_view<Features, feature_of<as_feature<mpl::_> > >
features_list;
typedef
typename feature_of<typename feature_tag<Accumulator>::type>::type
the_feature;
typedef
typename mpl::contains<features_list, the_feature>::type
type;
};
// This is to work around a bug in early versions of Fusion which caused
// a compile error if contains_feature_of<List, mpl::_> is used as a
// predicate to fusion::find_if
template<typename Features>
struct contains_feature_of_
{
template<typename Accumulator>
struct apply
: contains_feature_of<Features, Accumulator>
{};
};
template<
typename First
, typename Last
, bool is_empty = fusion::result_of::equal_to<First, Last>::value
>
struct build_acc_list;
template<typename First, typename Last>
struct build_acc_list<First, Last, true>
{
typedef fusion::nil type;
template<typename Args>
static fusion::nil
call(Args const &, First const&, Last const&)
{
return fusion::nil();
}
};
template<typename First, typename Last>
struct build_acc_list<First, Last, false>
{
typedef
build_acc_list<typename fusion::result_of::next<First>::type, Last>
next_build_acc_list;
typedef fusion::cons<
typename fusion::result_of::value_of<First>::type
, typename next_build_acc_list::type>
type;
template<typename Args>
static type
call(Args const &args, First const& f, Last const& l)
{
return type(args, next_build_acc_list::call(args, fusion::next(f), l));
}
};
namespace meta
{
template<typename Sequence>
struct make_acc_list
: build_acc_list<
typename fusion::result_of::begin<Sequence>::type
, typename fusion::result_of::end<Sequence>::type
>
{};
}
template<typename Sequence, typename Args>
typename meta::make_acc_list<Sequence>::type
make_acc_list(Sequence const &seq, Args const &args)
{
return meta::make_acc_list<Sequence>::call(args, fusion::begin(seq), fusion::end(seq));
}
///////////////////////////////////////////////////////////////////////////
// checked_as_weighted_feature
template<typename Feature>
struct checked_as_weighted_feature
{
typedef typename as_feature<Feature>::type feature_type;
typedef typename as_weighted_feature<feature_type>::type type;
// weighted and non-weighted flavors should provide the same feature.
BOOST_MPL_ASSERT((
is_same<
typename feature_of<feature_type>::type
, typename feature_of<type>::type
>
));
};
///////////////////////////////////////////////////////////////////////////
// as_feature_list
template<typename Features, typename Weight>
struct as_feature_list
: mpl::transform_view<Features, checked_as_weighted_feature<mpl::_1> >
{
};
template<typename Features>
struct as_feature_list<Features, void>
: mpl::transform_view<Features, as_feature<mpl::_1> >
{
};
///////////////////////////////////////////////////////////////////////////
// accumulator_wrapper
template<typename Accumulator, typename Feature>
struct accumulator_wrapper
: Accumulator
{
typedef Feature feature_tag;
accumulator_wrapper(accumulator_wrapper const &that)
: Accumulator(*static_cast<Accumulator const *>(&that))
{
}
template<typename Args>
accumulator_wrapper(Args const &args)
: Accumulator(args)
{
}
};
///////////////////////////////////////////////////////////////////////////
// to_accumulator
template<typename Feature, typename Sample, typename Weight>
struct to_accumulator
{
typedef
accumulator_wrapper<
typename mpl::apply2<typename Feature::impl, Sample, Weight>::type
, Feature
>
type;
};
template<typename Feature, typename Sample, typename Weight, typename Tag, typename AccumulatorSet>
struct to_accumulator<Feature, Sample, tag::external<Weight, Tag, AccumulatorSet> >
{
BOOST_MPL_ASSERT((is_same<Tag, void>));
BOOST_MPL_ASSERT((is_same<AccumulatorSet, void>));
typedef
accumulator_wrapper<
typename mpl::apply2<typename Feature::impl, Sample, Weight>::type
, Feature
>
accumulator_type;
typedef
typename mpl::if_<
typename Feature::is_weight_accumulator
, accumulator_wrapper<impl::external_impl<accumulator_type, tag::weights>, Feature>
, accumulator_type
>::type
type;
};
// BUGBUG work around a MPL bug wrt map insertion
template<typename FeatureMap, typename Feature>
struct insert_feature
: mpl::eval_if<
mpl::has_key<FeatureMap, typename feature_of<Feature>::type>
, mpl::identity<FeatureMap>
, mpl::insert<FeatureMap, mpl::pair<typename feature_of<Feature>::type, Feature> >
>
{
};
template<typename FeatureMap, typename Feature, typename Weight>
struct insert_dependencies
: mpl::fold<
as_feature_list<typename Feature::dependencies, Weight>
, FeatureMap
, insert_dependencies<
insert_feature<mpl::_1, mpl::_2>
, mpl::_2
, Weight
>
>
{
};
template<typename FeatureMap, typename Features, typename Weight>
struct insert_sequence
: mpl::fold< // BUGBUG should use insert_range, but doesn't seem to work for maps
as_feature_list<Features, Weight>
, FeatureMap
, insert_feature<mpl::_1, mpl::_2>
>
{
};
template<typename Features, typename Sample, typename Weight>
struct make_accumulator_tuple
{
typedef
typename mpl::fold<
as_feature_list<Features, Weight>
, mpl::map0<>
, mpl::if_<
mpl::is_sequence<mpl::_2>
, insert_sequence<mpl::_1, mpl::_2, Weight>
, insert_feature<mpl::_1, mpl::_2>
>
>::type
feature_map;
// for each element in the map, add its dependencies also
typedef
typename mpl::fold<
feature_map
, feature_map
, insert_dependencies<mpl::_1, mpl::second<mpl::_2>, Weight>
>::type
feature_map_with_dependencies;
// turn the map into a vector so we can sort it
typedef
typename mpl::insert_range<
mpl::vector<>
, mpl::end<mpl::vector<> >::type
, mpl::transform_view<feature_map_with_dependencies, mpl::second<mpl::_1> >
>::type
feature_vector_with_dependencies;
// sort the features according to which is derived from which
typedef
typename mpl::sort<
feature_vector_with_dependencies
, is_dependent_on<mpl::_2, mpl::_1>
>::type
sorted_feature_vector;
// From the vector of features, construct a vector of accumulators
typedef
typename mpl::transform<
sorted_feature_vector
, to_accumulator<mpl::_1, Sample, Weight>
>::type
type;
};
} // namespace detail
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,27 @@
///////////////////////////////////////////////////////////////////////////////
// external.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_EXTERNAL_HPP_EAN_01_12_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_EXTERNAL_HPP_EAN_01_12_2005
#include <boost/mpl/apply.hpp>
#include <boost/accumulators/framework/accumulators/external_accumulator.hpp>
//namespace boost { namespace accumulators
//{
//
/////////////////////////////////////////////////////////////////////////////////
//// external
////
//template<typename Type>
//struct external
//{
//};
//
//}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,229 @@
///////////////////////////////////////////////////////////////////////////////
// extractor.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005
#include <boost/preprocessor/tuple/rem.hpp>
#include <boost/preprocessor/array/size.hpp>
#include <boost/preprocessor/array/data.hpp>
#include <boost/preprocessor/array/elem.hpp>
#include <boost/preprocessor/seq/to_array.hpp>
#include <boost/preprocessor/seq/transform.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
#include <boost/parameter/binding.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/accumulators/framework/parameters/accumulator.hpp>
namespace boost { namespace accumulators
{
namespace detail
{
template<typename AccumulatorSet, typename Feature>
struct accumulator_set_result
{
typedef typename as_feature<Feature>::type feature_type;
typedef typename mpl::apply<AccumulatorSet, feature_type>::type::result_type type;
};
template<typename Args, typename Feature>
struct argument_pack_result
: accumulator_set_result<
typename remove_reference<
typename parameter::binding<Args, tag::accumulator>::type
>::type
, Feature
>
{
};
template<typename A, typename Feature>
struct extractor_result
: mpl::eval_if<
detail::is_accumulator_set<A>
, accumulator_set_result<A, Feature>
, argument_pack_result<A, Feature>
>
{
};
template<typename Feature, typename AccumulatorSet>
typename extractor_result<AccumulatorSet, Feature>::type
do_extract(AccumulatorSet const &acc, mpl::true_)
{
typedef typename as_feature<Feature>::type feature_type;
return extract_result<feature_type>(acc);
}
template<typename Feature, typename Args>
typename extractor_result<Args, Feature>::type
do_extract(Args const &args, mpl::false_)
{
typedef typename as_feature<Feature>::type feature_type;
return find_accumulator<feature_type>(args[accumulator]).result(args);
}
} // namespace detail
///////////////////////////////////////////////////////////////////////////////
/// Extracts the result associated with Feature from the specified accumulator_set.
template<typename Feature>
struct extractor
{
typedef extractor<Feature> this_type;
/// The result meta-function for determining the return type of the extractor
template<typename F>
struct result;
template<typename A1>
struct result<this_type(A1)>
: detail::extractor_result<A1, Feature>
{
};
/// Extract the result associated with Feature from the accumulator set
/// \param acc The accumulator set object from which to extract the result
template<typename Arg1>
typename detail::extractor_result<Arg1, Feature>::type
operator ()(Arg1 const &arg1) const
{
// Arg1 could be an accumulator_set or an argument pack containing
// an accumulator_set. Dispatch accordingly.
return detail::do_extract<Feature>(arg1, detail::is_accumulator_set<Arg1>());
}
/// \overload
///
/// \param a1 Optional named parameter to be passed to the accumulator's result() function.
template<typename AccumulatorSet, typename A1>
typename detail::extractor_result<AccumulatorSet, Feature>::type
operator ()(AccumulatorSet const &acc, A1 const &a1) const
{
BOOST_MPL_ASSERT((detail::is_accumulator_set<AccumulatorSet>));
typedef typename as_feature<Feature>::type feature_type;
return extract_result<feature_type>(acc, a1);
}
// ... other overloads generated by Boost.Preprocessor:
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_EXTRACTOR_FUN_OP(z, n, _) \
template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
struct result<this_type(BOOST_PP_ENUM_PARAMS_Z(z, n, A))> \
: detail::extractor_result<A1, Feature> \
{}; \
template< \
typename AccumulatorSet \
BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \
> \
typename detail::extractor_result<AccumulatorSet, Feature>::type \
operator ()( \
AccumulatorSet const &acc \
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
) const \
{ \
BOOST_MPL_ASSERT((detail::is_accumulator_set<AccumulatorSet>)); \
typedef typename as_feature<Feature>::type feature_type; \
return extract_result<feature_type>(acc BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a));\
}
BOOST_PP_REPEAT_FROM_TO(
2
, BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
, BOOST_ACCUMULATORS_EXTRACTOR_FUN_OP
, _
)
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
/// \overload
///
template<typename AccumulatorSet, typename A1, typename A2, ...>
typename detail::extractor_result<AccumulatorSet, Feature>::type
operator ()(AccumulatorSet const &acc, A1 const &a1, A2 const &a2, ...);
#endif
};
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_ARRAY_REM(Array) \
BOOST_PP_TUPLE_REM_CTOR(BOOST_PP_ARRAY_SIZE(Array), BOOST_PP_ARRAY_DATA(Array))
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_SEQ_REM(Seq) \
BOOST_ACCUMULATORS_ARRAY_REM(BOOST_PP_SEQ_TO_ARRAY(Seq))
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_ARGS_OP(s, data, elem) \
T ## s
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_PARAMS_OP(s, data, elem) \
elem T ## s
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) \
Tag::Feature< \
BOOST_ACCUMULATORS_SEQ_REM( \
BOOST_PP_SEQ_TRANSFORM(BOOST_ACCUMULATORS_ARGS_OP, ~, ParamsSeq) \
) \
>
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN_IMPL(z, n, Tag, Feature, ParamsSeq) \
template< \
BOOST_ACCUMULATORS_SEQ_REM( \
BOOST_PP_SEQ_TRANSFORM(BOOST_ACCUMULATORS_PARAMS_OP, ~, ParamsSeq) \
) \
, typename Arg1 \
BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \
> \
typename boost::accumulators::detail::extractor_result< \
Arg1 \
, BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) \
>::type \
Feature(Arg1 const &arg1 BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) ) \
{ \
typedef BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) feature_type; \
return boost::accumulators::extractor<feature_type>()( \
arg1 BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a)); \
}
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN(z, n, _) \
BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN_IMPL( \
z \
, n \
, BOOST_PP_ARRAY_ELEM(0, _) \
, BOOST_PP_ARRAY_ELEM(1, _) \
, BOOST_PP_ARRAY_ELEM(2, _) \
)
#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(Tag, Feature, ParamSeq) \
BOOST_PP_REPEAT( \
BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) \
, BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN \
, (3, (Tag, Feature, ParamSeq)) \
)
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,29 @@
///////////////////////////////////////////////////////////////////////////////
// features.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_STATISTICS_STATS_HPP_EAN_08_12_2005
#define BOOST_ACCUMULATORS_STATISTICS_STATS_HPP_EAN_08_12_2005
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
namespace boost { namespace accumulators
{
///////////////////////////////////////////////////////////////////////////////
// features
//
template<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature)>
struct features
: mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, Feature)>
{
};
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,20 @@
///////////////////////////////////////////////////////////////////////////////
// accumulator.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_ACCUMULATOR_HPP_EAN_31_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_ACCUMULATOR_HPP_EAN_31_10_2005
#include <boost/parameter/keyword.hpp>
namespace boost { namespace accumulators
{
BOOST_PARAMETER_KEYWORD(tag, accumulator)
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,20 @@
///////////////////////////////////////////////////////////////////////////////
// sample.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_SAMPLE_HPP_EAN_31_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_SAMPLE_HPP_EAN_31_10_2005
#include <boost/parameter/keyword.hpp>
namespace boost { namespace accumulators
{
BOOST_PARAMETER_KEYWORD(tag, sample)
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,21 @@
///////////////////////////////////////////////////////////////////////////////
// weight.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHT_HPP_EAN_31_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHT_HPP_EAN_31_10_2005
#include <boost/parameter/keyword.hpp>
namespace boost { namespace accumulators
{
// The weight of a single sample
BOOST_PARAMETER_KEYWORD(tag, weight)
}} // namespace boost::accumulators
#endif

View File

@@ -0,0 +1,21 @@
///////////////////////////////////////////////////////////////////////////////
// weights.hpp
//
// Copyright 2005 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHTS_HPP_EAN_28_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHTS_HPP_EAN_28_10_2005
#include <boost/parameter/keyword.hpp>
namespace boost { namespace accumulators
{
// The weight accumulator
BOOST_PARAMETER_KEYWORD(tag, weights)
}} // namespace boost::accumulators
#endif