1 // Copyright Neil Groves 2009. Use, modification and
2 // distribution is subject to the Boost Software License, Version
3 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
7 // For more information, see http://www.boost.org/libs/range/
9 #ifndef BOOST_RANGE_ALGORITHM_COUNT_HPP_INCLUDED
10 #define BOOST_RANGE_ALGORITHM_COUNT_HPP_INCLUDED
12 #include <boost/concept_check.hpp>
13 #include <boost/range/begin.hpp>
14 #include <boost/range/end.hpp>
15 #include <boost/range/concepts.hpp>
16 #include <boost/range/difference_type.hpp>
24 /// \brief template function count
26 /// range-based version of the count std algorithm
28 /// \pre SinglePassRange is a model of the SinglePassRangeConcept
29 template< class SinglePassRange, class Value >
30 inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange>::type
31 count(SinglePassRange& rng, const Value& val)
33 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
34 return std::count(boost::begin(rng), boost::end(rng), val);
38 template< class SinglePassRange, class Value >
39 inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange const>::type
40 count(const SinglePassRange& rng, const Value& val)
42 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
43 return std::count(boost::begin(rng), boost::end(rng), val);
50 #endif // include guard