Files

77 lines
2.2 KiB
C++

// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef ACTIV_BOOST_RANGE_SIZE_HPP
#define ACTIV_BOOST_RANGE_SIZE_HPP
#if defined(_MSC_VER)
# pragma once
#endif
#include <ActivBoost/range/config.hpp>
#include <ActivBoost/range/begin.hpp>
#include <ActivBoost/range/end.hpp>
#include <ActivBoost/range/size_type.hpp>
#include <ActivBoost/range/detail/has_member_size.hpp>
#include <ActivBoost/assert.hpp>
#include <ActivBoost/cstdint.hpp>
#include <ActivBoost/utility.hpp>
namespace Boost
{
namespace range_detail
{
template<class SinglePassRange>
inline typename ::Boost::enable_if<
has_member_size<SinglePassRange>,
typename range_size<const SinglePassRange>::type
>::type
range_calculate_size(const SinglePassRange& rng)
{
return rng.size();
}
template<class SinglePassRange>
inline typename disable_if<
has_member_size<SinglePassRange>,
typename range_size<const SinglePassRange>::type
>::type
range_calculate_size(const SinglePassRange& rng)
{
return std::distance(Boost::begin(rng), Boost::end(rng));
}
}
template<class SinglePassRange>
inline typename range_size<const SinglePassRange>::type
size(const SinglePassRange& rng)
{
// Very strange things happen on some compilers that have the range concept
// asserts disabled. This preprocessor condition is clearly redundant on a
// working compiler but is vital for at least some compilers such as clang 4.2
// but only on the Mac!
#if ACTIV_BOOST_RANGE_ENABLE_CONCEPT_ASSERT == 1
ACTIV_BOOST_RANGE_CONCEPT_ASSERT((Boost::SinglePassRangeConcept<SinglePassRange>));
#endif
#if !ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_BORLANDC, ACTIV_BOOST_TESTED_AT(0x564)) && \
!ACTIV_BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return range_calculate_size(rng);
}
} // namespace 'boost'
#endif