rotate_copy.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright Neil Groves 2009. Use, modification and
  2. // distribution is subject to the Boost Software License, Version
  3. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. //
  6. //
  7. // For more information, see http://www.boost.org/libs/range/
  8. //
  9. #ifndef BOOST_RANGE_ALGORITHM_ROTATE_COPY_HPP_INCLUDED
  10. #define BOOST_RANGE_ALGORITHM_ROTATE_COPY_HPP_INCLUDED
  11. #include <boost/concept_check.hpp>
  12. #include <boost/range/begin.hpp>
  13. #include <boost/range/end.hpp>
  14. #include <boost/range/concepts.hpp>
  15. #include <boost/range/iterator.hpp>
  16. #include <algorithm>
  17. namespace boost
  18. {
  19. namespace range
  20. {
  21. /// \brief template function rotate
  22. ///
  23. /// range-based version of the rotate std algorithm
  24. ///
  25. /// \pre Rng meets the requirements for a Forward range
  26. template<typename ForwardRange, typename OutputIterator>
  27. inline OutputIterator rotate_copy(
  28. const ForwardRange& rng,
  29. BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type middle,
  30. OutputIterator target
  31. )
  32. {
  33. BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
  34. return std::rotate_copy(boost::begin(rng), middle, boost::end(rng), target);
  35. }
  36. } // namespace range
  37. using range::rotate_copy;
  38. } // namespace boost
  39. #endif // include guard