
On 26.08.2011 20:21, Ovanes Markarian wrote:
On Fri, Aug 26, 2011 at 2:30 PM, Martin B. <0xCDCDCDCD@gmx.at mailto:0xCDCDCDCD@gmx.at> wrote:
Hi!
Say I have a range R and I want to construct a new container from the range R. Will I always have to repeat the expression yielding the range, or is there a shorter way?
Example:
std::vector<int> numbers( boost::irange(7, 42).begin(), boost::irange(7, 42).end() );
Note that it's just an example.
Is it possible to create a container C from a range expression R in one step? Any helper function for this?
What about that: ... integer_range<int> ir=irange(7,42); vector<int> numbers(ir.begin(), ir.end());
For this to work I need the exact type of the range, which can be quite
annoying as far as I could tell. (Plus, I *don't want* to care what type
of the range is.)
Really, if I had C++11/auto, I wouldn't mind so much, i.e.
auto xr = get_some_range(...);
vector<int> numbers(xr.begin(), xr.end());
but I don't have an `auto` capable compiler, so spelling out the range
type for this is really crappy.
Writing a make_container function seems fiddly wrt. to the C++03
reference type of the passed range, but maybe someone can help:
template