在使用Visual C ++中的一些新的C ++ 17功能时 - 我遇到了一个问题,对我来说这似乎是个bug。在使用编译器资源管理器在其他编译器下编译时,代码似乎按预期生成。生成的错误:
使用Visual Studio 2017 15.3.5
error C2027: use of undefined type 'std::tuple<unknown-type>'
note: see declaration of 'std::tuple<unknown-type>'
note: see reference to function template instantiation 'void DoSomething<>(void)' being compiled
error C2903: 'remove_reference_t': symbol is neither a class template nor a function template
#include <type_traits>
#include <tuple>
struct t_metadata
{
using type = int;
};
template<typename ...Types>
void DoSomething()
{
if constexpr (sizeof...(Types) < 1)
{
DoSomething<Types..., t_metadata>();
}
else
{
using T1 = std::remove_reference_t<decltype(std::get<0>(std::tuple<Types...>{}))>;
typename T1::type tempVal{ };
}
}
int main()
{
DoSomething<>();
return 0;
}