I though address-of-static was a constant expression as in the example below but I get a compiler error (or is this new to C++0x?)
class X {
static const int x;
enum { y = &x };
};
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Reading the 1998 standard, 5.19(1): “In several places, C++ requires expressions that evaluate to an integral or enumeration constant…as enumerator initializers (7.2)….”
Further, “An integral constant-expression can involve only….In particular, except in
sizeofexpressions, functions, class objects, pointers, or references shall not be used….”Floating literals are explicitly listed as castable to integral or enumeration type, and nothing else is.
Casting even an address constant expression to make an enumerator initializer was invalid from the first standard.