diff --git a/doc/reference/algorithm_ext/insert.qbk b/doc/reference/algorithm_ext/insert.qbk index 532e256..e9f48eb 100644 --- a/doc/reference/algorithm_ext/insert.qbk +++ b/doc/reference/algorithm_ext/insert.qbk @@ -11,10 +11,18 @@ template< class Container, class SinglePassRange - > +> Container& insert(Container& target, typename Container::iterator before, const SinglePassRange& from); + +// This overload is for target containers that do not require an insertion +// position e.g. set/map +template< + class Container, + class SinglePassRange +> +Container& insert(Container& target, const SinglePassRange& from); `` [heading Description] diff --git a/include/boost/range/algorithm_ext/insert.hpp b/include/boost/range/algorithm_ext/insert.hpp index b9adfdd..c0c04c8 100755 --- a/include/boost/range/algorithm_ext/insert.hpp +++ b/include/boost/range/algorithm_ext/insert.hpp @@ -29,12 +29,18 @@ inline Container& insert( Container& on, { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_ASSERT( (void*)&on != (void*)&from && - "cannot copy from a container to itself" ); on.insert( before, boost::begin(from), boost::end(from) ); return on; } +template< class Container, class Range > +inline Container& insert( Container& on, const Range& from ) +{ + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + on.insert(boost::begin(from), boost::end(from)); +} + } // namespace range using range::insert; } // namespace boost