|
Boost Users : |
Subject: Re: [Boost-users] [Range] insert algorithm fails if target is a map
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2012-03-27 06:19:09
On Wed, Nov 23, 2011 at 6:50 PM, Nathan Ridge <zeratul976_at_[hidden]>wrote:
>
> > The title says it all really. The failure occurs because the insert
> > algorithm expects the container
> > to provide a 3-arg insert of the form
> >
> > container.insert( position, begin, end );
> >
> > whereas map's, multimap's and set's insert method only takes two
> arguments...
> >
> > map.insert( begin, end );
> >
> > Is this limitation by design? It would be easy to provide
> > specialisations for maps, mmaps and sets, but
> > that would not be a completely general solution.
>
> I think what we really need is a second insert algorithm.
>
> The one we have right now:
>
> Container& insert(Container& target,
> typename Container::iterator before,
> const SinglePassRange& from);
>
> should call target.insert(before, begin, end), and only work for sequence
> containers,
>
> while a new one:
>
> Container& insert(Container& target,
> const SinglePassRange& from);
>
>
> should call target.insert(begin, end), and only work for associative
> containers
> (or any other container where you have no control over the position it's
> inserted
> at, e.g. a hypothetical sorted vector).
>
> I don't think it makes sense to try and get the first one to work for
> associative
> containers, because the "before" parameter is meaningless for those.
>
>
Darn.. bumped into this one again! Neil, is there any likelihood of any
action on this one? I think
Nate's suggestion would be ok, although it would introduce an overload
without some SFINAE protection.
Thx, Rob.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net