
7 Jun
2011
7 Jun
'11
2:36 p.m.
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