|
Boost Users : |
Subject: Re: [Boost-users] Ranges to Collections
From: John M. Dlugosz (mpbecey7gu_at_[hidden])
Date: 2011-06-07 10:36:35
On 6/6/2011 11:33 PM, Nathan Ridge wrote:
>
> I use this:
>
>
> template<typename Range>
> struct RangeWrapper
> {
> const Range& r;
>
> template<typename Container>
> operator Container() const
> {
> return Container(begin(r), end(r));
> }
> };
>
> template<typename Range>
> RangeWrapper<Range> range_to_container(const Range& r)
> {
> return RangeWrapper<Range>{r};
> }
>
>
> Simple but effective.
>
> Regards,
> Nate.
Yes, simple indeed.
What compiler are you using? I'm pretty sure Microsoft's doesn't support uniform
initialization syntax. But in this case, writing (r) instead and adding the constructor
to RangeWrapper should work just fine. It's just less simple <g>.
John
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