accumulators_fwd.hpp 8.1 KB

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