insert.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Boost.Range library
  2. //
  3. // Copyright Neil Groves 2009. 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_ALGORITHM_EXT_INSERT_HPP_INCLUDED
  11. #define BOOST_RANGE_ALGORITHM_EXT_INSERT_HPP_INCLUDED
  12. #include <boost/range/config.hpp>
  13. #include <boost/range/concepts.hpp>
  14. #include <boost/range/difference_type.hpp>
  15. #include <boost/range/begin.hpp>
  16. #include <boost/range/end.hpp>
  17. #include <boost/assert.hpp>
  18. namespace boost
  19. {
  20. namespace range
  21. {
  22. template< class Container, class Range >
  23. inline Container& insert( Container& on,
  24. BOOST_DEDUCED_TYPENAME Container::iterator before,
  25. const Range& from )
  26. {
  27. BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
  28. BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
  29. on.insert( before, boost::begin(from), boost::end(from) );
  30. return on;
  31. }
  32. template< class Container, class Range >
  33. inline Container& insert( Container& on, const Range& from )
  34. {
  35. BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
  36. BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
  37. on.insert(boost::begin(from), boost::end(from));
  38. return on;
  39. }
  40. } // namespace range
  41. using range::insert;
  42. } // namespace boost
  43. #endif // include guard