You can make this a compile time constant using:
template <int a, int b, int c, int d> struct FourCC { static const unsigned int value = (((((d << 8) | c) << 8) | b) << 8) | a; }; unsigned int id(FourCC<'a', 'b', 'c', 'd'>::value);
With a little effort, you can check it at compile time so that each number goes between 0 and 255.
source share