|
Boost : |
From: Alexander Nasonov (alnsn-mycop_at_[hidden])
Date: 2004-04-06 02:13:57
Thorsten Ottosen wrote:
>>I'd prefer to have on-fly container. Something like this:
>>
>>std::copy( on_fly % 1 % 2 % 3, on_fly_end<int>(), back_inserter<int>(v));
>>
>>Not as cool as v += 1, 2, 3; but might have some advantages.
>
> What would the advantages be?
This have advantage when the container is not available, only iterators
range.
template<class Iter>
void one_two_three(Iter begin, Iter end)
{
assert(distance(begin, end) >= 3);
copy(on_fly % 1 % 2 % 3, on_fly_end<int>(), begin);
}
It has some serious problem, though. For example, in
find(on_fly % 1 % 2 % 3, on_fly_end<int>(), 2);
return value points to temporary.
-- Alexander Nasonov Independent Developer and Consultant
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk