|
Boost Users : |
Subject: Re: [Boost-users] [foreach] BOOST_FOREACH question...
From: barcaroller (barcaroller_at_[hidden])
Date: 2010-01-07 21:40:16
"Dmitry Vinogradov" <sraider_at_[hidden]> wrote:
> To be short: it's not necessary.
>
> BTW, begin() and end() for an empty list are valid. You can't dereference
> them, but they are valid. So one can use them for comparison. And
> BOOST_FOREACH does.
I've had problems with standard 'for' loops when using empty containers:
for (i = mylist.begin() ; i != mylist.end() ; i++)
By problems I mean core-dumps, memory leaks, etc. These problems went away
when I used a size check:
if (!mylist.empty())
for (i = mylist.begin() ; i != mylist.end() ; i++)
This leads me to believe that begin() and end() are not valid, or is there
another way to explain this?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net