使用静态constexpr成员函数返回类内部的auto

eng*_*010 6 c++ constexpr auto c++14

我正在尝试解决我遇到的MSVC 2015中的错误(请参阅此问题: 函数签名的错误类型推导).

所以我想出了这个:

#include<Windows.h>

namespace wreg {

using t_oshandle     = HKEY;

struct t_api
{
    static constexpr 
    auto fnc_open_key ()     { return ::RegOpenKeyExA; }

    //this doesn't compile :
    static constexpr auto open_key   = fnc_open_key();

    //these don't compile either:
    //static constexpr decltype(fnc_open_key()) open_key     = fnc_open_key();
    //static constexpr decltype(::RegOpenKeyExA) open_key    = fnc_open_key();
};

//this does compiles and runs :
constexpr auto open_key  = t_api::fnc_open_key();

} // namespace wreg


//int main( int argc ,_TCHAR* argv[] );
{
    auto     hk = wreg::t_oshandle{};
    auto     res = wreg::t_api::open_key( HKEY_LOCAL_MACHINE ,"SOFTWARE" ,0 ,KEY_READ ,&hk );
    //auto   res = wreg::open_key( HKEY_LOCAL_MACHINE ,"SOFTWARE" ,0 ,KEY_READ ,&hk );

    if (res == ERROR_SUCCESS)
    {
        res = ::RegCloseKey( hk );
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但它不会因为编译而编译

错误C3779:'wreg :: t_api :: fnc_open_key':返回'auto'的函数在定义之前不能使用

我不明白.它在我使用它时明确定义.除此之外,在类中通常可以在定义/声明之前使用类定义的本地名称.

问题:为什么MSVC正确或我的代码应该编译?

eng*_*010 0

这不再是问题了。VS 2015 RTM 中解决了该错误。