unsigned int crc = CCompileTimeCRC6<'s','t','r','i','n','g'>::value;
#define CRC3(STRING) CCompileTimeCRC3<STRING[0], STRING[1], STRING[2]>::value
unsigned int crc = CRC3("abc");
unsigned int crc = CCompileTimeCRC6<'s','t','r','i','n','g'>::value;
#define CRC3(STRING) CCompileTimeCRC3<STRING[0], STRING[1], STRING[2]>::value
unsigned int crc = CRC3("abc");
error C2015: too many characters in constant
const __int64 = (const __int64)"foobar";
error C2971: a local variable cannot be used as a non-type argument
error C2970: an expression involving objects with internal linkage cannot be used as a non-type argument
error C2975: invalid template argument, expected compile-time constant expression
template <int string>class Test{public: enum { value = string; }};const int temp = 'test';int b = Test< temp >::value;
Quote:Original post by _moagstar_But unfortunately the compiler does not see these as compile time values.#define CRC3(STRING) CCompileTimeCRC3<STRING[0], STRING[1], STRING[2]>::value unsigned int crc = CRC3("abc");
#include "stdafx.h" #include <iostream> int main(int argc, char* argv[]) { std::cout << "hello world"[0]; std::cout << "hello world"[1]; std::cout << "hello world"[2]; std::cout << "hello world"[3]; std::cout << "hello world"[4]; std::cout << "hello world"[5]; std::cout << "hello world"[6]; std::cout << "hello world"[7]; std::cout << "hello world"[8]; std::cout << "hello world"[9]; std::cout << "hello world"[10]; std::cout << std::endl; return 0; }