1 /////////////////////////////////////////////////////////////////////////////// 2 // error_of.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 8 #ifndef BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_HPP_EAN_29_11_2005 9 #define BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_HPP_EAN_29_11_2005 10 11 #include <boost/mpl/placeholders.hpp> 12 #include <boost/accumulators/framework/accumulator_base.hpp> 13 #include <boost/accumulators/framework/extractor.hpp> 14 #include <boost/accumulators/framework/depends_on.hpp> 15 #include <boost/accumulators/statistics_fwd.hpp> 16 17 namespace boost { namespace accumulators 18 { 19 20 namespace impl 21 { 22 /// INTERNAL ONLY 23 /// 24 template<typename Feature> 25 struct this_feature_has_no_error_calculation 26 : mpl::false_ 27 { 28 }; 29 30 /////////////////////////////////////////////////////////////////////////////// 31 // error_of_impl 32 /// INTERNAL ONLY 33 /// 34 template<typename Sample, typename Feature> 35 struct error_of_impl 36 : accumulator_base 37 { 38 // TODO: specialize this on the specific features that have errors we're 39 // interested in. 40 BOOST_MPL_ASSERT((this_feature_has_no_error_calculation<Feature>)); 41 42 // for boost::result_of 43 typedef int result_type; 44 error_of_implboost::accumulators::impl::error_of_impl45 error_of_impl(dont_care) 46 { 47 } 48 resultboost::accumulators::impl::error_of_impl49 result_type result(dont_care) const 50 { 51 return 0; 52 } 53 }; 54 55 } // namespace impl 56 57 /////////////////////////////////////////////////////////////////////////////// 58 // tag::error_of 59 // 60 namespace tag 61 { 62 template<typename Feature> 63 struct error_of 64 : depends_on<Feature> 65 { 66 /// INTERNAL ONLY 67 /// 68 typedef accumulators::impl::error_of_impl<mpl::_1, Feature> impl; 69 }; 70 } 71 72 /////////////////////////////////////////////////////////////////////////////// 73 // extract::error_of 74 // 75 namespace extract 76 { 77 BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, error_of, (typename)) 78 } 79 80 using extract::error_of; 81 82 // make tag::error_of<tag::feature(modifier)> work 83 template<typename Feature> 84 struct as_feature<tag::error_of<Feature> > 85 { 86 typedef tag::error_of<typename as_feature<Feature>::type> type; 87 }; 88 89 // make error_of<tag::mean> work with non-void weights (should become 90 // error_of<tag::weighted_mean> 91 template<typename Feature> 92 struct as_weighted_feature<tag::error_of<Feature> > 93 { 94 typedef tag::error_of<typename as_weighted_feature<Feature>::type> type; 95 }; 96 97 }} // namespace boost::accumulators 98 99 #endif 100