With C++11, the above would be possible for basic types as
class Foo {
public:
static constexpr int MEMBER = 1;
};
The constexpr
part creates a static expression as opposed to a static variable - and that behaves just like an extremely simple inline method definition. The approach proved a bit wobbly with C-string constexprs inside template classes, though.