C++ constexpr不';好像不行

C++ constexpr不';好像不行,c++,c++11,constexpr,C++,C++11,Constexpr,我正在使用Visual Studio 2013+CTP 我定义了以下函数: constexpr DWORD const_getHash(const char *str, DWORD curHash = 0) { return !*str ? curHash : const_getHash(str + 1, (curHash >> 13 | curHash << (32 - 13)) + (*str >= 'a' ? *str - 32 :

我正在使用Visual Studio 2013+CTP

我定义了以下函数:

constexpr DWORD const_getHash(const char *str, DWORD curHash = 0) {
    return !*str ? curHash : const_getHash(str + 1, 
        (curHash >> 13 | curHash << (32 - 13)) + (*str >= 'a' ? *str - 32 : *str));
}
编译器没有发出任何警告,但通过查看“反汇编”,我可以判断const_getHash()是在运行时执行的

怎么了

编辑:如果我强制在编译时使用

constexpr DWORD hash = const_getHash("ok");
编译器说

Error   1   error C2127: 'hash': illegal initialization of 'constexpr' entity with a non-constant expression

constexpr
不强制在编译时执行函数。它只是告诉编译器,如果需要,可以在编译时执行函数

constexpr
函数的所有参数都是常量表达式且结果也用于常量表达式时,将在编译时对其求值


(引自公认的答案。)

这可能是VS编译器的一些限制,因为它在@TomKnapen-dam上工作!我可能会转向GCC。我无法在运行时计算哈希,因为我正在编写一个外壳代码,它需要尽可能小。
Error   1   error C2127: 'hash': illegal initialization of 'constexpr' entity with a non-constant expression