相关疑难解决方法(0)

成员函数实例化

以下汇编在GCC 4.8.1(with --std=c++11)上:

struct non_default_constructible { non_default_constructible() = delete; };

template<class T>
struct dummy {
    T new_t() { return T(); }
};

int main(int argc, char** argv) {
    dummy<non_default_constructible> d;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

棘手的部分dummy<non_default_constructible>::new_t()显然是格式不正确,但这并不妨碍编译器实例化dummy<non_default_constructible>.

这是标准规定的行为吗?什么是相关的部分/关键字?

c++ templates

10
推荐指数
1
解决办法
1865
查看次数

标签 统计

c++ ×1

templates ×1