[C++-sig] Class scoped enum losing scope

Hans Meine meine at informatik.uni-hamburg.de
Thu Feb 5 09:51:50 CET 2009

On Thursday 05 February 2009 02:58:08 Rao, Sumeeth wrote:
> >>> import Boost_FooBar
> >>>
> >>> bar = Boost_FooBar.Bar()
> >>>
> >>> var = Boost_FooBar.Foo.eType.TYPE_B           < --Seems to understand
> that there is a  Foo::etype::TYPE_B value
> >>> var
> Boost_FooBar.eType.TYPE_B               <------------------ var seems to
> have "lost" the scope of class Foo!

Yes, that's ugly, and also poses problems with pickling.  (The same problem 
affects other nested types, i.e. classes.)

> >>> stat = bar.barfun(Boost_FooBar.Foo.eType.TYPE_B)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> Boost.Python.ArgumentError: Python argument types in
>     Bar.barfun(Bar, Boost_FooBar.eType)                 < ------ Why is the
> parameter not of type Boost_FooBar.Foo.eType?

I am not sure that this is the problem; as you demonstrated above, boost will 
forget about the scope, but you should still be able to use 'var' normally 
IIRC.  Maybe your error is somewhere else?  E.g. did you try to expose a 
global function 'barfun' instead of a Bar member function?  (I am unsure, and 
I never used bp::wrapper so far.)


More information about the Cplusplus-sig mailing list