forked from boostorg/range
added algorithm_ext insert algorithm for containers without a where iterator.
This commit is contained in:
@ -11,10 +11,18 @@
|
|||||||
template<
|
template<
|
||||||
class Container,
|
class Container,
|
||||||
class SinglePassRange
|
class SinglePassRange
|
||||||
>
|
>
|
||||||
Container& insert(Container& target,
|
Container& insert(Container& target,
|
||||||
typename Container::iterator before,
|
typename Container::iterator before,
|
||||||
const SinglePassRange& from);
|
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]
|
[heading Description]
|
||||||
|
@ -29,12 +29,18 @@ inline Container& insert( Container& on,
|
|||||||
{
|
{
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
|
||||||
BOOST_ASSERT( (void*)&on != (void*)&from &&
|
|
||||||
"cannot copy from a container to itself" );
|
|
||||||
on.insert( before, boost::begin(from), boost::end(from) );
|
on.insert( before, boost::begin(from), boost::end(from) );
|
||||||
return on;
|
return on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template< class Container, class Range >
|
||||||
|
inline Container& insert( Container& on, const Range& from )
|
||||||
|
{
|
||||||
|
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
|
||||||
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
|
||||||
|
on.insert(boost::begin(from), boost::end(from));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace range
|
} // namespace range
|
||||||
using range::insert;
|
using range::insert;
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
Reference in New Issue
Block a user