c++ - Replace macro with constexpr function to define enum -


i have macro such

#define ascii_to_3bit(c) c & 0x60 - 1

i have tried replace this:

constexpr const std::uint8_t ascii_to_3bit(char c) {     return c & 0x60 - 1; } 

i using this:

enum class column {     = ascii_to_3bit('a'),     b = ascii_to_3bit('b'),     c = ascii_to_3bit('c'),     d = ascii_to_3bit('d'),     e = ascii_to_3bit('e'),     f = ascii_to_3bit('f'),     g = ascii_to_3bit('g'),     h = ascii_to_3bit('h') }; 

it works fine macro dies "function call must have constant value constant expression" when function.

is possible? compiler whatever vs2015 ships.


Comments