[C++-sig] Re: Pyste bug with unnamed enums
Roman Yakovenko
roman.yakovenko at actimize.com
Wed Feb 18 16:50:02 CET 2004
Okay. I understand your answer. Than you.
But I steel have to export unnamed enum.
What do you think about declaring them as consts ( within scope of module / class ) ?
It seems me that this is a way I should go.
More over this is exactly their meaning in my code.
Thanks you for help. Roman
> -----Original Message-----
> From: David Abrahams [mailto:dave at boost-consulting.com]
> Sent: Tuesday, February 17, 2004 6:38 PM
> To: c++-sig at python.org
> Subject: [C++-sig] Re: Pyste bug with unnamed enums
>
>
> "Roman Yakovenko" <roman.yakovenko at actimize.com> writes:
>
> > Hi. I found bug in Pyste.
> >
> > Description:
> > In your code you have 2 unnamed enum definitions
> >
> > enum { SOME_CONST_1 = 32 };
> > enum { SOME_CONST_2 = 46 };
> >
> > after running pyste on this code you will get
> >
> > // Unique type for unnamed enums
> > #ifndef PYSTE_UNIQUE_INT_DEFINED
> > #define PYSTE_UNIQUE_INT_DEFINED
> > template<int num>
> > struct UniqueInt {
> > int v;
> > enum { value=num };
> > UniqueInt(int v_):
> > v(v_)
> > {}
> > operator int() const
> > { return v; }
> > };
> > #endif // PYSTE_UNIQUE_INT_DEFINED
> >
> > generated twice ( if you generate your code to the same module ).
> >
> > The possible solution are:
> > 1. To ask David Abrahams how we should export unnamed enums (
> > defined within class and within some namespace ).
>
> Name them. If you can't name them, you can't export them. You can't
> even pass them through a function template:
>
> enum { x = 1 };
>
> template <class T>
> int f(T);
>
> int y = f(x); // error
>
> Sorry.
>
> > 2. To use unnamed enums as global constants for enums
> defined within namespace.
> > To define new class attribute if enum defined within class.
> > 3. To put definition of UniqueInt within BPL
>
> :(
>
> I don't really know what UniqueInt is supposed to do, but I don't
> love it because it's not unique ;-)
>
> enum { x = 1 }
> enum { y = 1 }
>
>
> BOOST_STATIC_ASSERT((boost::is_same<UniqueInt<x>,UniqueInt<y>
> >::value));
>
>
> --
> Dave Abrahams
> Boost Consulting
> www.boost-consulting.com
>
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>
More information about the Cplusplus-sig
mailing list