|
Boost Users : |
Subject: Re: [Boost-users] [range] Best way to construct a std::set from a range?
From: Gabriel Redner (gredner_at_[hidden])
Date: 2010-03-03 13:43:57
Sure, that works - I was hoping for something that fits naturally on
one line, though.
Thanks,
-Gabe
On Wed, Mar 3, 2010 at 10:54 AM, Mathias Gaunard
<mathias.gaunard_at_[hidden]> wrote:
> Gabriel Redner wrote:
>>
>> If I have a pair of iterators, I can construct a set like so:
>>
>> std::set<SomeType> s(it1, it2);
>>
>> If instead I have a range, I can adapt it like so:
>>
>> std::set<SomeType> s(boost::begin(range), boost::end(range));
>>
>> However, my range object is being constructed on the fly. I'd like to
>> be able to do:
>>
>> std::set<SomeType> s(MakeRange(args));
>
> what about
>
> template<typename Container>
> void assign_range(Container& c, const Range& r)
> {
> c.assign(begin(r), end(r));
> }
>
> std::set<SomeType> s;
> assign_range(s, MakeRange(args));
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
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