Re: [boost] Metaprogramming: Using static const or enum?

2003-01-11 Thread Paul Mensonides
- Original Message - From: "David Abrahams" <[EMAIL PROTECTED]> > > I guess it would depend heavily on the compiler used. For instance, a > > compiler might not actually create the storage at all unless the address of > > the static const is actually needed--which would cause the effect t

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-11 Thread David Abrahams
"Paul Mensonides" <[EMAIL PROTECTED]> writes: > - Original Message - > From: "David Abrahams" <[EMAIL PROTECTED]> > > >> "Paul Mensonides" <[EMAIL PROTECTED]> writes: >> >> >> > Well, yes. If you do that, however, it removes one of the primary >> > reasons >> >> > to use enumerations, whi

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-11 Thread Paul Mensonides
- Original Message - From: "David Abrahams" <[EMAIL PROTECTED]> > "Paul Mensonides" <[EMAIL PROTECTED]> writes: > > >> > Well, yes. If you do that, however, it removes one of the primary > > reasons > >> > to use enumerations, which is for the syntactic convenience. The only > >> > reas

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-11 Thread David Abrahams
"Paul Mensonides" <[EMAIL PROTECTED]> writes: >> > Well, yes. If you do that, however, it removes one of the primary > reasons >> > to use enumerations, which is for the syntactic convenience. The only >> > reason left to use enums is to avoid the static storage of the >> > values. >> >> And to

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-11 Thread Paul Mensonides
- Original Message - From: "David Abrahams" <[EMAIL PROTECTED]> > >> Now Y::value and Y::value have the same type. Of course, > >> you will probably want some additional tools in integral_c, like > >> an explicit conversion to an rvalue of type T. > Misread it, sorry. > >

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-11 Thread David Abrahams
"Paul Mensonides" <[EMAIL PROTECTED]> writes: > - Original Message - > From: "David Abrahams" <[EMAIL PROTECTED]> > >> > solution: >> > >> > There is no non-intrusive solution. It must be cast at the call site to > a >> > common type (such as 'int' or 'bool') in order to avoid replicated

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-11 Thread Paul Mensonides
- Original Message - From: "David Abrahams" <[EMAIL PROTECTED]> > > solution: > > > > There is no non-intrusive solution. It must be cast at the call site to a > > common type (such as 'int' or 'bool') in order to avoid replicated template > > instantiation. > > > > */ > > Of course,

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-11 Thread David Abrahams
"Paul Mensonides" <[EMAIL PROTECTED]> writes: > func( Y::value ); // okay. > > // A temporary is created of type 'Y::value_type'. > // The address of that temporary is bound to > // the const& parameter of 'func'. > // 'func' is instantiated with 'T' == 'Y::va

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-11 Thread Paul Mensonides
- Original Message - From: "Terje Slettebø" <[EMAIL PROTECTED]> > Right, but members of anonymous namespaces does have external linkage, so > this is not an example of that. That's an advantage over the deprecated > file-scope static, which does have internal linkage, and is therefore > u

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-11 Thread Terje Slettebø
>From: "Paul Mensonides" <[EMAIL PROTECTED]> > > 14.3.1/2 [quote-- > > > > A local type, a type with no linkage, an unnamed type or a type compounded > > from any of these types shall not be used as a template-argument for a > > template type-parameter. > > > > --end quote] > > Incidently, an unna

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-11 Thread Gabriel Dos Reis
"Paul Mensonides" <[EMAIL PROTECTED]> writes: [...] | However, this | raises another interesting problem. Many enumerations used for this purpose | are unnamed: | | template struct is_ptr { | enum { value = false }; | }; | | templat

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-09 Thread Paul Mensonides
- Original Message - From: "Daniel Frey" <[EMAIL PROTECTED]> Terje Slettebø wrote: > > > Just to make sure: Do you "vote" in favor of enums? I have seen problems > > with 'static const ...', but I have never seen problems with enums > > (although they theoretically exist). > > Not just the

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-09 Thread Gabriel Dos Reis
Daniel Frey <[EMAIL PROTECTED]> writes: | > Yes, a smarter compiler may do better, but such smarter compilers are | > quite rare :-) | > Yes, the thingy ends up in the link map (as a local symbol). | | Just to make sure: Do you "vote" in favor of enums? I'm a long term pro-enum (mostly because f

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-09 Thread Daniel Frey
Terje Slettebø wrote: > > > Just to make sure: Do you "vote" in favor of enums? I have seen problems > > with 'static const ...', but I have never seen problems with enums > > (although they theoretically exist). > > Not just theoretically. As mentioned in an earlier posting in this thread, > BCC

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-09 Thread Terje Slettebø
>From: "Daniel Frey" <[EMAIL PROTECTED]> > Gabriel Dos Reis wrote: > > > > I'm not one the authors of the book mentioned but I will say what I > > know (from experience both as a user and casual implementor). The > > issue of enum/static const is an endless debate. However, one thing is > > sure:

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-09 Thread Daniel Frey
Gabriel Dos Reis wrote: > > I'm not one the authors of the book mentioned but I will say what I > know (from experience both as a user and casual implementor). The > issue of enum/static const is an endless debate. However, one thing is > sure: Even with the amended paragraph in the Standard (re

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-08 Thread Gabriel Dos Reis
David Abrahams <[EMAIL PROTECTED]> writes: | Terje Slettebø <[EMAIL PROTECTED]> writes: | | > Static constant members are lvalues. So, if you have a declaration such as | > | > void foo(int const&); | > | > and you pass it the result of a metaprogram | > | > foo(Pow3<7>::result); | > | > a compil

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-07 Thread David Abrahams
Terje Slettebø <[EMAIL PROTECTED]> writes: > Static constant members are lvalues. So, if you have a declaration such as > > void foo(int const&); > > and you pass it the result of a metaprogram > > foo(Pow3<7>::result); > > a compiler must pass the address of Pow3<7>::result, which forces > the co

Re: [boost] Metaprogramming: Using static const or enum?

2003-01-07 Thread Daniel Frey
Terje Slettebø wrote: > > BOOST_STATIC_CONST is defined in Boost.Config as: > > # ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION > # define BOOST_STATIC_CONSTANT(type, assignment) enum { assignment } > # else > # define BOOST_STATIC_CONSTANT(type, assignment) static const type > assignm

[boost] Metaprogramming: Using static const or enum?

2003-01-07 Thread Terje Slettebø
Hi. BOOST_STATIC_CONST is defined in Boost.Config as: # ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION # define BOOST_STATIC_CONSTANT(type, assignment) enum { assignment } # else # define BOOST_STATIC_CONSTANT(type, assignment) static const type assignment # endif Thus, it prefers sta