/Src/Dependencies/Boost/boost/range/adaptor/indirected.hpp

http://hadesmem.googlecode.com/ · C++ Header · 88 lines · 65 code · 14 blank · 9 comment · 0 complexity · a7a1d1265ad8c759ad95be29cc0ff51e MD5 · raw file

  1. // Boost.Range library
  2. //
  3. // Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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_ADAPTOR_INDIRECTED_HPP
  11. #define BOOST_RANGE_ADAPTOR_INDIRECTED_HPP
  12. #include <boost/range/iterator_range.hpp>
  13. #include <boost/iterator/indirect_iterator.hpp>
  14. namespace boost
  15. {
  16. namespace range_detail
  17. {
  18. template< class R >
  19. struct indirected_range :
  20. public boost::iterator_range<
  21. boost::indirect_iterator<
  22. BOOST_DEDUCED_TYPENAME range_iterator<R>::type
  23. >
  24. >
  25. {
  26. private:
  27. typedef boost::iterator_range<
  28. boost::indirect_iterator<
  29. BOOST_DEDUCED_TYPENAME range_iterator<R>::type
  30. >
  31. >
  32. base;
  33. public:
  34. explicit indirected_range( R& r )
  35. : base( r )
  36. { }
  37. };
  38. struct indirect_forwarder {};
  39. template< class InputRng >
  40. inline indirected_range<InputRng>
  41. operator|( InputRng& r, indirect_forwarder )
  42. {
  43. return indirected_range<InputRng>( r );
  44. }
  45. template< class InputRng >
  46. inline indirected_range<const InputRng>
  47. operator|( const InputRng& r, indirect_forwarder )
  48. {
  49. return indirected_range<const InputRng>( r );
  50. }
  51. } // 'range_detail'
  52. using range_detail::indirected_range;
  53. namespace adaptors
  54. {
  55. namespace
  56. {
  57. const range_detail::indirect_forwarder indirected =
  58. range_detail::indirect_forwarder();
  59. }
  60. template<class InputRange>
  61. inline indirected_range<InputRange>
  62. indirect(InputRange& rng)
  63. {
  64. return indirected_range<InputRange>(rng);
  65. }
  66. template<class InputRange>
  67. inline indirected_range<const InputRange>
  68. indirect(const InputRange& rng)
  69. {
  70. return indirected_range<const InputRange>(rng);
  71. }
  72. } // 'adaptors'
  73. }
  74. #endif