push_back.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_PUSH_BACK_HPP_INCLUDED
  11. #define BOOST_RANGE_ALGORITHM_EXT_PUSH_BACK_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/range/detail/implementation_help.hpp>
  18. #include <boost/assert.hpp>
  19. namespace boost
  20. {
  21. namespace range
  22. {
  23. template< class Container, class Range >
  24. inline Container& push_back( Container& on, const Range& from )
  25. {
  26. BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Container> ));
  27. BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const Range> ));
  28. BOOST_ASSERT_MSG(!range_detail::is_same_object(on, from),
  29. "cannot copy from a container to itself");
  30. on.insert( on.end(), boost::begin(from), boost::end(from) );
  31. return on;
  32. }
  33. } // namespace range
  34. using range::push_back;
  35. } // namespace boost
  36. #endif // include guard