/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. #ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006
  8. #define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006
  9. #include <boost/mpl/always.hpp>
  10. #include <boost/parameter/keyword.hpp>
  11. #include <boost/accumulators/framework/depends_on.hpp> // for feature_tag
  12. #include <boost/accumulators/framework/accumulator_base.hpp>
  13. #include <boost/accumulators/framework/extractor.hpp>
  14. namespace boost { namespace accumulators
  15. {
  16. namespace impl
  17. {
  18. //////////////////////////////////////////////////////////////////////////
  19. // value_accumulator_impl
  20. template<typename ValueType, typename Tag>
  21. struct value_accumulator_impl
  22. : accumulator_base
  23. {
  24. typedef ValueType result_type;
  25. template<typename Args>
  26. value_accumulator_impl(Args const &args)
  27. : val(args[parameter::keyword<Tag>::get()])
  28. {
  29. }
  30. result_type result(dont_care) const
  31. {
  32. return this->val;
  33. }
  34. private:
  35. ValueType val;
  36. };
  37. } // namespace impl
  38. namespace tag
  39. {
  40. //////////////////////////////////////////////////////////////////////////
  41. // value_tag
  42. template<typename Tag>
  43. struct value_tag
  44. {
  45. };
  46. //////////////////////////////////////////////////////////////////////////
  47. // value
  48. template<typename ValueType, typename Tag>
  49. struct value
  50. : depends_on<>
  51. {
  52. /// INTERNAL ONLY
  53. ///
  54. typedef mpl::always<accumulators::impl::value_accumulator_impl<ValueType, Tag> > impl;
  55. };
  56. }
  57. namespace extract
  58. {
  59. BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value, (typename)(typename))
  60. BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value_tag, (typename))
  61. }
  62. using extract::value;
  63. using extract::value_tag;
  64. // Map all value<V,T> features to value_tag<T> so
  65. // that values can be extracted using value_tag<T>
  66. // without specifying the value type.
  67. template<typename ValueType, typename Tag>
  68. struct feature_of<tag::value<ValueType, Tag> >
  69. : feature_of<tag::value_tag<Tag> >
  70. {
  71. };
  72. }} // namespace boost::accumulators
  73. #endif