实例化 问答列表

显式实例化定义:类模板的构造函数模板——可能吗?(Clang 与 GCC)

作者:Vittorio Romeo 提问时间:3/17/2023

请考虑以下类模板: template <typename> struct S { template <typename T> void f(T) { /* ... */ } }; 可以提...

在存在类模板成员函数的显式专用化的情况下使用“extern template”时出错

作者:Vittorio Romeo 提问时间:3/17/2023

考虑一个类模板:S [s.hpp] template <typename> struct S { void f() { /* ... */ } void g() { /* ... */ } }...

如何避免每次编译项目时都重新编译特定的模板函数?[复制]

作者:SirVivor 提问时间:5/22/2023

这个问题在这里已经有答案了: 使用 extern 模板 (C++11) 避免实例化( 5 个答案) 使用“外部模板”来防止模板类的隐式实例化 (2 个答案) C++ 11 外部模板:我们实际上在哪里需...

跨多个库的显式实例化

作者:Anon232 提问时间:6/15/2023

如果我有一些带有模板实现的标题: #ifndef FOOHEADER_HPP #define FOOHEADER_HPP template <typename T> struct Foo { voi...

将游戏对象分配给游戏对象的 2D 数组将返回 null

作者:Anthony Ghosn 提问时间:6/22/2023

我有一个 GameObject 的 2D 数组,我想从 2 for 循环中分配一个游戏对象,但分配返回 null。 void PlaceBricks(){ placedBricksPositio...

为什么(隐式)实例化函数模板可以使用未声明的符号?

作者:Jan Schultke 提问时间:7/14/2023

我有以下代码: template <typename T> void fun(T t) { // foo and bar are not declared yet, but this is oka...

C++ 模板:尽管存在错误,但没有编译错误 [重复]

作者:O.T.Vinta 提问时间:8/16/2023

这个问题在这里已经有答案了: C++ 模板未报告局部变量错误 (1 个答案) C++ 编译器未检测到类模板中的错误 (4 个答案) 是否在不实例化 C++ 模板的情况下检查它们是否存在语法错误? (2...

getInstance() 方法如何工作以及为什么不使用 new 关键字?

作者:David 提问时间:8/30/2023

我注意到在创建对实例的引用时没有使用关键字。下面是代码片段:new public class SingletonExample { private static SingletonExample ...


共38条 当前第4页