Boost logo

Boost Users :

Subject: Re: [Boost-users] Using boost_foreach with c++ enumerations
From: Eric Niebler (eniebler_at_[hidden])
Date: 2013-08-05 19:37:16


On 8/5/2013 10:49 AM, Tim Burgess wrote:
> Hi,
>
> Is it possible to use boost_foreach to iterate over the members of a c++
> enum? If so, can anybody point me to an example?

No. BOOST_FOREACH is for ranges, and an enum is not a range. There is no
way to do what you're asking because C++ doesn't have the reflection
capabilities needed to iterate through all members of an enum.

-- 
Eric Niebler
Boost.org
http://www.boost.org

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