jjzjj

Templated

全部标签

javascript - 道场 : Inheriting/Extending templated widgets : How to?

我创建了一个名为“Dialog”的模板化基本小部件,我想将其用作包中所有其他小部件的核心布局小部件。这是一个带有几个连接点的简单容器。(我没有包含HTML,因为它非常简单)define("my/Dialog",["dojo/_base/declare","dijit/_WidgetBase","dijit/_TemplatedMixin","dijit/_WidgetsInTemplateMixin","dojo/ready","dojo/parser","dojo/text!./Dialog.html"],function(declare,_WidgetBase,_Templated

c++ - 警告 C4661 :no suitable definition provided for explicit template instantiation request

我写了一个类模板并在不同的DLL中使用它,所以希望隐藏部分实现。为此,我使用“模板实例化”,但导出它,像这样,这里是头文件:#include#includeusingnamespacestd;templateclass__declspec(dllexport)Templated{public:Templated();};template__declspec(dllexport)Templated;intmain(){cout并且定义在单独的文件(.cpp)中templateTemplated::Templated(){}templateTemplated;我的问题是我收到警告,即使实例

c++ - 错误 : expected primary-expression before ‘>’ : templated function that try to uses a template method of the class for which is templated

这个问题在这里已经有了答案:WhereandwhydoIhavetoputthe"template"and"typename"keywords?(8个答案)关闭8年前。在使用模板和仿函数(未出现在这个问题中)时,我最终遇到了以下简化的问题。以下代码(也可用here)classA{public:templateboolisGood(intin)const{constTf;returninbooltryEvaluator(T&evaluator,intvalue){returnevaluator.isGood(value);}intmain(intargc,constchar*argv[]

c++ - 为什么 C+ +'s <vector> templated class doesn' t 打破了一个定义规则?

也许这是一个蹩脚的问题,但我不明白!如果我包括或在多个翻译单元(不同的.cpp)中,为什么它不破坏ODR?据我所知,每个.cpp的编译方式都不同,因此将为每个目标文件分别生成vector的方法代码,对吧?所以链接器应该检测到它并提示。即使它不会(我怀疑这是模板的特殊情况),当我将所有链接在一起时,它会在每个单元中使用一个代码还是不同的克隆代码集??? 最佳答案 同样,任何模板定义都不会破坏ODR—ODR特别指出,模板定义可以在翻译单元之间重复,只要它们确实是重复的(并且,因为它们是重复,不可能有冲突或歧义)。[C++14:3.2/6

C++ 链接错误 : Undefined symbols using a templated class

我在编写的类中遇到了一些非常奇怪的链接错误。我完全找不到任何可以描述正在发生的事情的东西。VisualStudio(WindowsXP)players.obj:errorLNK2019:unresolvedexternalsymbol"public:__thiscallTreeNode::TreeNode(void)"(??0?$TreeNode@VPlayer@@@@QAE@XZ)referencedinfunction"public:__thiscallPlayerList::PlayerList(void)"(??0PlayerList@@QAE@XZ)Xcode(OSX10.5

c++ - GCC/VS2008 : Different behaviour of function call when templated base class is derived from itself

以下代码适用于VisualStudio2008,但不适用于GCC/G++4.3.420090804。根据C++标准,哪种行为正确?templatestructA:A{};templatestructA{};structB:A{};templatevoidFunc(constA&a){}intmain(){Aa;//isderivedfromAFunc(a);//vs2008:ok,g++:ok//Comeau:okBb;//isderivedfromAFunc(b);//vs2008:ok,g++:error,nomatchingfunctionforcalltoFunc(B&)//C

c++ - GCC/VS2008 : Different behaviour of function call when templated base class is derived from itself

以下代码适用于VisualStudio2008,但不适用于GCC/G++4.3.420090804。根据C++标准,哪种行为正确?templatestructA:A{};templatestructA{};structB:A{};templatevoidFunc(constA&a){}intmain(){Aa;//isderivedfromAFunc(a);//vs2008:ok,g++:ok//Comeau:okBb;//isderivedfromAFunc(b);//vs2008:ok,g++:error,nomatchingfunctionforcalltoFunc(B&)//C

c++ - 仿函数 : templated struct vs templated operator()

标准库函数对象的通常模式是拥有一个带有非模板operator()的模板化结构。例如,std::less看起来像这样:templatestructless{booloperator()(constT&lhs,constT&rhs)const{returnlhsvec=...;std::sort(vec.begin(),vec.end(),less{});我的问题是,为什么这比具有模板化operator()的非模板结构更好?看起来上面的仿函数在操作上等同于:structless2{templatebooloperator()(constT&lhs,constT&rhs)const{retu

c++ - QT : Templated Q_OBJECT class

是否有可能有一个模板类,它继承自QObject(并且在它的声明中有Q_OBJECT宏)?我想为插槽创建类似适配器的东西,它会做一些事情,但插槽可以接受任意数量的参数(参数数量取决于模板参数)。我只是尝试这样做,但出现链接器错误。我猜这个模板类没有调用gmake或moc。有没有办法做到这一点?也许通过显式实例化模板? 最佳答案 模板和Q_OBJECT不能混合使用,但如果您有类型的子集,您可以像这样列出插槽和信号:classSignalsSlots:publicQObject{Q_OBJECTpublic:explicitSignals

c++ - QT : Templated Q_OBJECT class

是否有可能有一个模板类,它继承自QObject(并且在它的声明中有Q_OBJECT宏)?我想为插槽创建类似适配器的东西,它会做一些事情,但插槽可以接受任意数量的参数(参数数量取决于模板参数)。我只是尝试这样做,但出现链接器错误。我猜这个模板类没有调用gmake或moc。有没有办法做到这一点?也许通过显式实例化模板? 最佳答案 模板和Q_OBJECT不能混合使用,但如果您有类型的子集,您可以像这样列出插槽和信号:classSignalsSlots:publicQObject{Q_OBJECTpublic:explicitSignals
12