[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-cpp-sig
Subject:    [C++-sig] enum strangeness...
From:       dave () boost-consulting ! com (David Abrahams)
Date:       2005-11-10 16:08:49
Message-ID: u7jbg4h9q.fsf () boost-consulting ! com
[Download RAW message or body]

Alex Mohr <amohr at pixar.com> writes:

> I noticed something today about enums that I've wrapped with 
> boost.python.  Here's a small example.
>
> #include <boost/python.hpp>
> using namespace boost::python;
>
> struct Foo {
> 	enum Bar { Baz };
> };
>
> BOOST_PYTHON_MODULE(Mod) {
> 	scope fooScope = class_<Foo>("Foo");
> 	enum_<Foo::Bar>("Bar")
> 		.value("Baz", Foo::Baz)
> 		.export_values();
> }
>
> Now, in Python I can refer to the enum values by saying 'Mod.Foo.Baz' 
> which is what I expect, but it seems to recur in a strange way.  I can 
> also say:
>
> Mod.Foo.Baz.Baz.Baz.Baz.Baz.Baz.Baz.Baz
>
> for as long as I like.  This seems relatively benign, but strange.  Is 
> it expected?

Yeah, an enum's values are members of its type, and you can access
members of a type through its instances.  No surprise.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic