/Src/Dependencies/Boost/boost/range/size.hpp

http://hadesmem.googlecode.com/ · C++ Header · 52 lines · 35 code · 7 blank · 10 comment · 2 complexity · 1e95c1420e00989530fbde0aa4429aa4 MD5 · raw file

  1. // Boost.Range library
  2. //
  3. // Copyright Thorsten Ottosen 2003-2004. Use, modification and
  4. // distribution is subject to the Boost Software License, Version
  5. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // For more information, see http://www.boost.org/libs/range/
  9. //
  10. #ifndef BOOST_RANGE_SIZE_HPP
  11. #define BOOST_RANGE_SIZE_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif
  15. #include <boost/range/config.hpp>
  16. #include <boost/range/begin.hpp>
  17. #include <boost/range/end.hpp>
  18. #include <boost/range/difference_type.hpp>
  19. #include <boost/assert.hpp>
  20. namespace boost
  21. {
  22. namespace range_detail
  23. {
  24. template<class SinglePassRange>
  25. inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange>::type
  26. range_calculate_size(const SinglePassRange& rng)
  27. {
  28. BOOST_ASSERT( (boost::end(rng) - boost::begin(rng)) >= 0 &&
  29. "reachability invariant broken!" );
  30. return boost::end(rng) - boost::begin(rng);
  31. }
  32. }
  33. template<class SinglePassRange>
  34. inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange>::type
  35. size(const SinglePassRange& rng)
  36. {
  37. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
  38. !BOOST_WORKAROUND(__GNUC__, < 3) \
  39. /**/
  40. using namespace range_detail;
  41. #endif
  42. return range_calculate_size(rng);
  43. }
  44. } // namespace 'boost'
  45. #endif