constexpr initializing static member using static function
Requirements I want a constexpr value (i.e. a compile-time constant) computed from a constexpr function. And I want both of these scoped to the namespace of a class, i.e. a static method and a static member of the class. First attempt I first wrote this the (to me) obvious way: class C1 { constexpr static int foo(int x) { return x + 1; } constexpr static int bar = foo(sizeof(int)); }; g++-4.5.3 -std=gnu++0x says to that: error: ‘static int C1::foo(int)’ cannot appear in a constant-expression error: a function call cannot appear in a constant-expression g++-4.6.3 -std=gnu++0x complains: error: