Boost logo

Boost :

Subject: Re: [boost] [Review] Type Traits Introspection library by Edward Diener starts tomorrow Friday 1
From: Edward Diener (eldiener_at_[hidden])
Date: 2011-07-02 12:18:40


On 7/2/2011 11:41 AM, John Maddock wrote:
>>> No, but you *may* need an out-of-line definition for the member "value"
>>> if the compiler considers the address to be "used": my guess is you're
>>> only using it within the context of another metafunction, so probably
>>> this should be OK.... probably ;)
>>
>> Is there a relevant section in the C++ standard about this which you
>> can cite offhand ?
>>
>> In my quick test of this I did not specify an out-of-line definition
>> but then again I am not "using" the const value in any other way then
>> to test against it.
>
> C++11 says of these:
>
> "If a non-volatile const static data member is of integral or
> enumeration type, its declaration in the class
> definition can specify a brace-or-equal-initializer in which every
> initializer-clause that is an assignmentexpression
> is a constant expression (5.19). A static data member of literal type
> can be declared in the
> class definition with the constexpr specifier; if so, its declaration
> shall specify a brace-or-equal-initializer
> in which every initializer-clause that is an assignment-expression is a
> constant expression. [ Note: In both
> these cases, the member may appear in constant expressions. -end note ]
> The member shall still be defined
> in a namespace scope if it is odr-used (3.2) in the program and the
> namespace scope definition shall not
> contain an initializer."
>
> I couldn't find in 3.2 where it specifies what constitutes odr-used in
> this case, but I did note that unevaluated-operands are excluded, so if
> you're using it within a constant-expression it seems you may be OK.

I am using it within a constant expression since TTI is a compile-time
library like type traits. But I am sure you already know that.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk