it_pair.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // (C) Copyright Gennadiy Rozental 2001.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. // File : $RCSfile$
  8. //
  9. // Version : $Revision: 74248 $
  10. //
  11. // Description : support for backward compatible collection comparison interface
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_TOOLS_DETAIL_IT_PAIR_HPP_112812GER
  14. #define BOOST_TEST_TOOLS_DETAIL_IT_PAIR_HPP_112812GER
  15. #ifdef BOOST_TEST_NO_OLD_TOOLS
  16. #include <boost/test/detail/suppress_warnings.hpp>
  17. //____________________________________________________________________________//
  18. namespace boost {
  19. namespace test_tools {
  20. namespace tt_detail {
  21. // ************************************************************************** //
  22. // ************** backward compatibility support ************** //
  23. // ************************************************************************** //
  24. template<typename It>
  25. struct it_pair {
  26. typedef It const_iterator;
  27. typedef typename std::iterator_traits<It>::value_type value_type;
  28. it_pair( It const& b, It const& e ) : m_begin( b ), m_size( 0 )
  29. {
  30. It tmp = b;
  31. while( tmp != e ) { ++m_size; ++tmp; }
  32. }
  33. It begin() const { return m_begin; }
  34. It end() const { return m_begin + m_size; }
  35. size_t size() const { return m_size; }
  36. private:
  37. It m_begin;
  38. size_t m_size;
  39. };
  40. //____________________________________________________________________________//
  41. template<typename It>
  42. it_pair<It>
  43. make_it_pair( It const& b, It const& e ) { return it_pair<It>( b, e ); }
  44. //____________________________________________________________________________//
  45. template<typename T>
  46. it_pair<T const*>
  47. make_it_pair( T const* b, T const* e ) { return it_pair<T const*>( b, e ); }
  48. //____________________________________________________________________________//
  49. } // namespace tt_detail
  50. } // namespace test_tools
  51. } // namespace boost
  52. #include <boost/test/detail/enable_warnings.hpp>
  53. #endif // BOOST_TEST_NO_OLD_TOOLS
  54. #endif // BOOST_TEST_TOOLS_DETAIL_IT_PAIR_HPP_112812GER