|
Geometry : |
Subject: [ggl] pre-/post-increment op on iterators
From: Mateusz Loskot (mateusz)
Date: 2009-04-28 09:21:23
Bruno Lalande wrote:
>> typedef vector<pair<int, pair<float, float> > > v_t;
>> // use v_t later in the code
>> ...
>> BOOST_FOREACH(v_t::value_type p, v)
>
> If the typedef is already needed somewhere else, it's a solution. The
> problem is that there exist more and more tools (make_xxx functions,
> auto keyword or BOOST_AUTO, etc...) that make those typedefs less and
> less often needed.
Yes, I agree.
>> Yes, I found it convenient too.
>> However, I can understand the rationale behind BOOST_FOREACH.
>> Even if it does require explicit use of value_type, on the other
>> hand it frees you from knowledge about how container/collection is
>> being iterated. Iteration is hidden as it is by algorithms.
>> Second, if functor introduces extra entities into code,
>> and in some cases it may make code less readable/understandable.
>> BOOST_FOREACH is handy as replacement for simple loop, plus it
>> provides nice genericness.
>
> Yep, all approaches have their drawbacks and advantages, indeed. So I
> don't really bother if somebody uses one or the other,
Same here.
> I simply wait
> for the concept-based C++0x for_each that will solve everything :-)
:-)
Best regards
-- Mateusz Loskot, http://mateusz.loskot.net
Geometry list run by mateusz at loskot.net