accumulators_fwd.hpp 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // accumulators_fwd.hpp
  3. //
  4. // Copyright 2005 Eric Niebler. 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. #ifndef BOOST_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005
  8. #define BOOST_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005
  9. #include <boost/config.hpp>
  10. #include <boost/mpl/apply_fwd.hpp> // for mpl::na
  11. #include <boost/mpl/limits/vector.hpp>
  12. #include <boost/preprocessor/cat.hpp>
  13. #include <boost/preprocessor/arithmetic/inc.hpp>
  14. #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
  15. #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
  16. #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
  17. #include <boost/preprocessor/repetition/repeat_from_to.hpp>
  18. #include <boost/accumulators/numeric/functional_fwd.hpp>
  19. #ifndef BOOST_ACCUMULATORS_MAX_FEATURES
  20. /// The maximum number of accumulators that may be put in an accumulator_set.
  21. /// Defaults to BOOST_MPL_LIMIT_VECTOR_SIZE (which defaults to 20).
  22. # define BOOST_ACCUMULATORS_MAX_FEATURES BOOST_MPL_LIMIT_VECTOR_SIZE
  23. #endif
  24. #if BOOST_ACCUMULATORS_MAX_FEATURES > BOOST_MPL_LIMIT_VECTOR_SIZE
  25. # error BOOST_ACCUMULATORS_MAX_FEATURES cannot be larger than BOOST_MPL_LIMIT_VECTOR_SIZE
  26. #endif
  27. #ifndef BOOST_ACCUMULATORS_MAX_ARGS
  28. /// The maximum number of arguments that may be specified to an accumulator_set's
  29. /// accumulation function. Defaults to 15.
  30. # define BOOST_ACCUMULATORS_MAX_ARGS 15
  31. #endif
  32. #if BOOST_WORKAROUND(__GNUC__, == 3) \
  33. || BOOST_WORKAROUND(__EDG_VERSION__, BOOST_TESTED_AT(306))
  34. # define BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS
  35. #endif
  36. #ifdef BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS
  37. # include <boost/utility/enable_if.hpp>
  38. # include <boost/type_traits/is_const.hpp>
  39. # define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T)\
  40. , typename boost::disable_if<boost::is_const<T> >::type * = 0
  41. #else
  42. # define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T)
  43. #endif
  44. #define BOOST_ACCUMULATORS_GCC_VERSION \
  45. (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  46. namespace boost { namespace accumulators
  47. {
  48. ///////////////////////////////////////////////////////////////////////////////
  49. // Named parameters tags
  50. //
  51. namespace tag
  52. {
  53. struct sample;
  54. struct weight;
  55. struct accumulator;
  56. struct weights;
  57. }
  58. ///////////////////////////////////////////////////////////////////////////////
  59. // User-level features
  60. //
  61. namespace tag
  62. {
  63. template<typename ValueType, typename Tag>
  64. struct value;
  65. template<typename Tag>
  66. struct value_tag;
  67. template<typename Referent, typename Tag>
  68. struct reference;
  69. template<typename Tag>
  70. struct reference_tag;
  71. template<typename Type, typename Tag = void, typename AccumulatorSet = void>
  72. struct external;
  73. template<typename Feature>
  74. struct droppable;
  75. }
  76. template<typename Accumulator>
  77. struct droppable_accumulator_base;
  78. template<typename Accumulator>
  79. struct droppable_accumulator;
  80. template<typename Accumulator>
  81. struct with_cached_result;
  82. template<typename Sample, typename Features, typename Weight = void>
  83. struct accumulator_set;
  84. template<typename Feature>
  85. struct extractor;
  86. template<typename Feature>
  87. struct feature_of;
  88. template<typename Feature>
  89. struct as_feature;
  90. template<typename Feature>
  91. struct as_weighted_feature;
  92. template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)>
  93. struct depends_on;
  94. template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)>
  95. struct features;
  96. template<typename Feature, typename AccumulatorSet>
  97. typename mpl::apply<AccumulatorSet, Feature>::type const &
  98. find_accumulator(AccumulatorSet const &acc);
  99. template<typename Feature, typename AccumulatorSet>
  100. typename mpl::apply<AccumulatorSet, Feature>::type::result_type
  101. extract_result(AccumulatorSet const &acc);
  102. template<typename Feature, typename AccumulatorSet, typename A1>
  103. typename mpl::apply<AccumulatorSet, Feature>::type::result_type
  104. extract_result(AccumulatorSet const &acc, A1 const &a1);
  105. // ... other overloads generated by Boost.Preprocessor:
  106. /// INTERNAL ONLY
  107. ///
  108. #define BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD(z, n, _) \
  109. template< \
  110. typename Feature \
  111. , typename AccumulatorSet \
  112. BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \
  113. > \
  114. typename mpl::apply<AccumulatorSet, Feature>::type::result_type \
  115. extract_result( \
  116. AccumulatorSet const &acc \
  117. BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
  118. );
  119. /// INTERNAL ONLY
  120. ///
  121. BOOST_PP_REPEAT_FROM_TO(
  122. 2
  123. , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
  124. , BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD
  125. , _
  126. )
  127. #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
  128. template<typename Feature, typename AccumulatorSet, typename A1, typename A2 ...>
  129. typename mpl::apply<AccumulatorSet, Feature>::type::result_type
  130. extract_result(AccumulatorSet const &acc, A1 const &a1, A2 const &a2 ...);
  131. #endif
  132. namespace impl
  133. {
  134. using namespace numeric::operators;
  135. template<typename Accumulator, typename Tag>
  136. struct external_impl;
  137. }
  138. namespace detail
  139. {
  140. template<typename Accumulator>
  141. struct feature_tag;
  142. template<typename Feature, typename Sample, typename Weight>
  143. struct to_accumulator;
  144. struct accumulator_set_base;
  145. template<typename T>
  146. struct is_accumulator_set;
  147. inline void ignore_variable(void const *) {}
  148. #define BOOST_ACCUMULATORS_IGNORE_GLOBAL(X) \
  149. namespace detail \
  150. { \
  151. struct BOOST_PP_CAT(ignore_, X) \
  152. { \
  153. void ignore() \
  154. { \
  155. boost::accumulators::detail::ignore_variable(&X); \
  156. } \
  157. }; \
  158. } \
  159. /**/
  160. }
  161. }} // namespace boost::accumulators
  162. // For defining boost::parameter keywords that can be inherited from to
  163. // get a nested, class-scoped keyword with the requested alias
  164. #define BOOST_PARAMETER_NESTED_KEYWORD(tag_namespace, name, alias) \
  165. namespace tag_namespace \
  166. { \
  167. template<int Dummy = 0> \
  168. struct name ## _ \
  169. { \
  170. static char const* keyword_name() \
  171. { \
  172. return #name; \
  173. } \
  174. static ::boost::parameter::keyword<name ## _<Dummy> > &alias; \
  175. }; \
  176. template<int Dummy> \
  177. ::boost::parameter::keyword<name ## _<Dummy> > &name ## _<Dummy>::alias = \
  178. ::boost::parameter::keyword<name ## _<Dummy> >::get(); \
  179. typedef name ## _ <> name; \
  180. } \
  181. namespace \
  182. { \
  183. ::boost::parameter::keyword<tag_namespace::name> &name = \
  184. ::boost::parameter::keyword<tag_namespace::name>::get(); \
  185. }
  186. #endif