|
Boost : |
From: John Torjo (john.lists_at_[hidden])
Date: 2004-04-21 12:23:13
Alexander Nasonov wrote:
>Alexander Nasonov wrote:
>
>
>
>>David Abrahams wrote:
>>
>>
>>
>>>John Torjo <john.lists_at_[hidden]> writes:
>>>
>>>
>>>
>>>>>You can also use the rtl (Ranges Template Library):
>>>>>(note: I'll rename the library, wince there's another one with the
>>>>>same name ;))
>>>>>
>>>>>for( crange<container> r(cont); r; ++r)
>>>>> *r += 2;
>>>>>
>>>>>
>>>>>
>>>>p.s. no macros involved in the above statement ;)
>>>>Best,
>>>>John
>>>>
>>>>
>>>That said, you do have have to name the container type. At the same
>>>time, you don't have to name the element type ;-)
>>>
>>>
>>You could get rid of the container type if you recall any_pointer idea.
>>But this monster is too slow to be an iterator :)
>>
>>
>
>Another idea. The any_pointer could be made lightweighted. ScopedGuard trick
>can help, on one hand, to hide ugly container type behind typedef'd
>reference, and, on another hand, to let the compiler remember the "origin".
>I suspect the compiler have to be very very clever.
>
>// aka ScopedGuard; library code
>typedef crange_base const& crange_base_ref;
>
>// user code
>for(crange_base_ref r = make_crange(cont); r; ++r)
> *r += 2;
>
>
>
you'd need a very smart compiler indeed ;) One that would twist the
rules a bit, since the above is not legal C++.
Best,
John
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk