Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:07:51

0001 // Boost.Range library
0002 //
0003 //  Copyright Thorsten Ottosen 2003-2004. Use, modification and
0004 //  distribution is subject to the Boost Software License, Version
0005 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0006 //  http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // For more information, see http://www.boost.org/libs/range/
0009 //
0010 
0011 #ifndef BOOST_RANGE_SIZE_HPP
0012 #define BOOST_RANGE_SIZE_HPP
0013 
0014 #if defined(_MSC_VER)
0015 # pragma once
0016 #endif
0017 
0018 #include <boost/range/config.hpp>
0019 #include <boost/range/begin.hpp>
0020 #include <boost/range/end.hpp>
0021 #include <boost/range/size_type.hpp>
0022 #include <boost/range/detail/has_member_size.hpp>
0023 #include <boost/assert.hpp>
0024 #include <boost/cstdint.hpp>
0025 #include <boost/utility.hpp>
0026 
0027 namespace boost
0028 {
0029     namespace range_detail
0030     {
0031 
0032         template<class SinglePassRange>
0033         inline typename ::boost::enable_if<
0034             has_member_size<SinglePassRange>,
0035             typename range_size<const SinglePassRange>::type
0036         >::type
0037         range_calculate_size(const SinglePassRange& rng)
0038         {
0039             return rng.size();
0040         }
0041 
0042         template<class SinglePassRange>
0043         inline typename disable_if<
0044             has_member_size<SinglePassRange>,
0045             typename range_size<const SinglePassRange>::type
0046         >::type
0047         range_calculate_size(const SinglePassRange& rng)
0048         {
0049             return std::distance(boost::begin(rng), boost::end(rng));
0050         }
0051     }
0052 
0053     template<class SinglePassRange>
0054     inline typename range_size<const SinglePassRange>::type
0055     size(const SinglePassRange& rng)
0056     {
0057 // Very strange things happen on some compilers that have the range concept
0058 // asserts disabled. This preprocessor condition is clearly redundant on a
0059 // working compiler but is vital for at least some compilers such as clang 4.2
0060 // but only on the Mac!
0061 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT == 1
0062         BOOST_RANGE_CONCEPT_ASSERT((boost::SinglePassRangeConcept<SinglePassRange>));
0063 #endif
0064 
0065 #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) && \
0066     !BOOST_WORKAROUND(__GNUC__, < 3) \
0067     /**/
0068         using namespace range_detail;
0069 #endif
0070 
0071         return range_calculate_size(rng);
0072     }
0073 
0074 } // namespace 'boost'
0075 
0076 #endif