Chris@16: // Boost.Range library Chris@16: // Chris@16: // Copyright Thorsten Ottosen 2003-2004. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // For more information, see http://www.boost.org/libs/range/ Chris@16: // Chris@16: Chris@16: #ifndef BOOST_RANGE_SIZE_HPP Chris@16: #define BOOST_RANGE_SIZE_HPP Chris@16: Chris@101: #if defined(_MSC_VER) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@101: #include Chris@16: #include Chris@101: #include Chris@101: #include Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: namespace range_detail Chris@16: { Chris@101: Chris@16: template Chris@101: inline typename ::boost::enable_if< Chris@101: has_member_size, Chris@101: typename range_size::type Chris@101: >::type Chris@16: range_calculate_size(const SinglePassRange& rng) Chris@16: { Chris@101: return rng.size(); Chris@101: } Chris@101: Chris@101: template Chris@101: inline typename disable_if< Chris@101: has_member_size, Chris@101: typename range_size::type Chris@101: >::type Chris@101: range_calculate_size(const SinglePassRange& rng) Chris@101: { Chris@101: return std::distance(boost::begin(rng), boost::end(rng)); Chris@16: } Chris@16: } Chris@16: Chris@16: template Chris@101: inline typename range_size::type Chris@16: size(const SinglePassRange& rng) Chris@16: { Chris@16: #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ Chris@16: !BOOST_WORKAROUND(__GNUC__, < 3) \ Chris@16: /**/ Chris@16: using namespace range_detail; Chris@16: #endif Chris@16: return range_calculate_size(rng); Chris@16: } Chris@16: Chris@16: } // namespace 'boost' Chris@16: Chris@16: #endif