Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:20

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // max.hpp
0003 //
0004 //  Copyright 2005 Eric Niebler. Distributed under the Boost
0005 //  Software License, Version 1.0. (See accompanying file
0006 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 #ifndef BOOST_ACCUMULATORS_STATISTICS_MAX_HPP_EAN_28_10_2005
0009 #define BOOST_ACCUMULATORS_STATISTICS_MAX_HPP_EAN_28_10_2005
0010 
0011 #include <limits>
0012 #include <boost/mpl/placeholders.hpp>
0013 #include <boost/accumulators/framework/accumulator_base.hpp>
0014 #include <boost/accumulators/framework/extractor.hpp>
0015 #include <boost/accumulators/framework/parameters/sample.hpp>
0016 #include <boost/accumulators/numeric/functional.hpp>
0017 #include <boost/accumulators/framework/depends_on.hpp>
0018 #include <boost/accumulators/statistics_fwd.hpp>
0019 
0020 namespace boost { namespace accumulators
0021 {
0022 
0023 namespace impl
0024 {
0025     ///////////////////////////////////////////////////////////////////////////////
0026     // max_impl
0027     template<typename Sample>
0028     struct max_impl
0029       : accumulator_base
0030     {
0031         // for boost::result_of
0032         typedef Sample result_type;
0033 
0034         template<typename Args>
0035         max_impl(Args const &args)
0036           : max_(numeric::as_min(args[sample | Sample()]))
0037         {
0038         }
0039 
0040         template<typename Args>
0041         void operator ()(Args const &args)
0042         {
0043             numeric::max_assign(this->max_, args[sample]);
0044         }
0045 
0046         result_type result(dont_care) const
0047         {
0048             return this->max_;
0049         }
0050 
0051         // make this accumulator serializeable
0052         template<class Archive>
0053         void serialize(Archive & ar, const unsigned int /* file_version */)
0054         {
0055             ar & max_;
0056         }
0057 
0058     private:
0059         Sample max_;
0060     };
0061 
0062 } // namespace impl
0063 
0064 ///////////////////////////////////////////////////////////////////////////////
0065 // tag::max
0066 //
0067 namespace tag
0068 {
0069     struct max
0070       : depends_on<>
0071     {
0072         /// INTERNAL ONLY
0073         ///
0074         typedef accumulators::impl::max_impl<mpl::_1> impl;
0075     };
0076 }
0077 
0078 ///////////////////////////////////////////////////////////////////////////////
0079 // extract::max
0080 //
0081 namespace extract
0082 {
0083     extractor<tag::max> const max = {};
0084 
0085     BOOST_ACCUMULATORS_IGNORE_GLOBAL(max)
0086 }
0087 
0088 using extract::max;
0089 
0090 }} // namespace boost::accumulators
0091 
0092 #endif