相关疑难解决方法(0)

回归虚空?

我不明白为什么这段代码编译没有错误:

#include <iostream>

template <class T>
struct Test
{
    static constexpr T f() {return T();} 
};

int main()
{
    Test<void> test;
    test.f(); // Why not an error?
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

根据标准是否可以,还是编译器容差?

c++ templates return void c++11

26
推荐指数
2
解决办法
1055
查看次数

标签 统计

c++ ×1

c++11 ×1

return ×1

templates ×1

void ×1