Boost logo

Boost Users :

Subject: [Boost-users] [foreach] BOOST_FOREACH question...
From: barcaroller (barcaroller_at_[hidden])
Date: 2010-01-07 18:31:59


Does the BOOST_FOREACH macro work for empty sequences or must a size check
be done explicitly?

        list<int> mylist;

        if (!mylist.empty()) // <--- necessary?
        {
            foreach(int& i, mylist)
            {
                // take action
            }
        }

The reason I ask is that neither begin() nor end() return valid iterators
for empty sequences, but it is my understanding that BOOST_FOREACH needs
iterators to work properly.


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