Reputation: 4663
Is there any way to initialize enum value like this:
enum Test
{
X = function("X")
};
Currently in Visual Studio I get this error:
error C2057: expected constant expression
And Visual Studio doesn't support constexpr
Upvotes: 3
Views: 463
Reputation: 1863
The enumerator list within an enum declaration is defined as follows:
enumerator-list - comma-separated list of enumerator definitions, each of which is either simply an identifier, which becomes the name of the enumerator, or an identifier with an initializer: identifier = constexpr
You may only use constant expressions.
Upvotes: 4