Boost logo

Boost :

Subject: Re: [boost] [Review] Type Traits Introspection library by Edward Diener starts tomorrow Friday 1
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-07-02 11:41:41


>> 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.

John.


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