草庐IT

template_directory

全部标签

c++ - 错误 : use of deleted function for overloaded template

我正在尝试模板特化,但无法确定为什么charconst*const无法在下面解析(尽管是有效类型)的原因。templateBfoo(A)=delete;templatevoidfoo(char*){}templatevoidfoo(charconst*const){}intmain(){{//typesOKcharconst*consta=nullptr;char*b=nullptr;}char*data;foo(data);//OKfoo(data);//ERRORreturn0;}错误error:useofdeletedfunction‘Bfoo(A)[withA=constcha

c++ - "run time templates"

我很确定答案是“你不能使用模板,你必须使用虚函数(动态多态性)”,但如果我走那条路,我似乎必须复制很多代码.这是设置:我目前有两个类,ColorImageSegmentation和GrayscaleImageSegmentation。他们做的事情本质上是一样的,但是有3个区别-它们对不同类型(ColorImage和GrayscaleImage)进行操作-一个参数,直方图的维度(3vs1)不同-PixelDifference函数根据图像类型不同如果我创建一个类templateclassImageSegmentation{};我会保持良好的状态。但是,我想让这个对象成为另一个类的成员:cl

c++ - 了解 "template argument is invalid"错误消息

考虑代码:#include#includestructtest1{voidInvoke(){};};structtest2{templatevoidInvoke(){};};enumclassInvokableKind{NOT_INVOKABLE,INVOKABLE_FUNCTION,INVOKABLE_FUNCTION_TEMPLATE};templatestructget_invokable_kind{conststaticInvokableKindvalue=InvokableKind::NOT_INVOKABLE;};templatestructget_invokable_ki

c++ - 'Windows.h : No such file or directory"error when changing Platform Toolset to v140_xp

这个问题在这里已经有了答案:HowtotargetWindowsXPinMicrosoftVisualStudioC++[duplicate](2个答案)关闭4年前。我尝试为WindowsXP编译一个应用程序;正常的可执行文件给出错误:"...isnotavalidWin32application."我读到我可以通过将平台工具集更改为VisualStudio2015-WindowsXP(v140_xp)来创建与XP兼容的可执行文件,但是当我这样做然后尝试编译时,它给了我以下错误:Cannotopenincludefile:'Windows.h':Nosuchfileordirector

c++ - template<> 用于成员枚举的显式特化

根据17.7.3[temp.expl.spec]第5段(N4659),...Membersofanexplicitlyspecializedclasstemplatearedefinedinthesamemannerasmembersofnormalclasses,andnotusingthetemplatesyntax.Thesameistruewhendefiningamemberofanexplicitlyspecializedmemberclass.However,templateisusedindefiningamemberofanexplicitlyspecializedm

c++ - 想要 : a C++ template idea to catch an issue, 但在编译时?

我们有一个常量结构数组,像这样:staticconstSettingsSuT_table[]={{5,1},{1,2},{1,1},etc};结构如下:size_bytes:num_items:其他“元数据”成员所以“总大小”是单个元素的size_bytes*num_items。所有这些信息都在const数组中,在编译时可用。但是,请注意,_table的总大小与EEPROM本身的大小无关。_table不镜像EEPROM,它只描述了布局、用途和我们需要的其他“元数据”类型的信息。但是,您可以使用此元数据来确定我们正在使用的EEPROM的数量。数组简单地描述了存储在外部EEPROM中的数据

c++ - Visual Studio 作为代码浏览器 : How to preserve the directory structure?

我下载了一个开源C++项目的源代码。这是一个Linux项目。由于VisualStudio是我最喜欢的IDE,我想用它来浏览和研究代码。我创建了一个空的C++项目,现在想将源代码添加到解决方案资源管理器。如何将目录结构添加到“解决方案资源管理器”。在解决方案资源管理器中将源代码的根文件夹拖放到项目上不起​​作用。它只是将文件添加到项目中,但目录结构丢失了。有什么办法可以保留目录结构吗?我不想手动重新创建目录结构。 最佳答案 如果您将项目文件添加到项目根目录,然后在“解决方案资源管理器”面板中切换到“显示所有文件”(选择项目中的文件),

c++ - 错误 C2995 : function template has already been defined

此代码产生17错误C2995:函数模板已被定义;在添加#include"set.h"header之前存在一组单独的错误。有一个与此关联的私有(private).cpp和.h文件。/**File:private/set.cpp*LastmodifiedonThuJun1109:34:082009byeroberts*-----------------------------------------------------*Thisfilecontainstheimplementationoftheset.hinterface.*BecauseofthewayC++compilestemp

c++ - 两阶段查找 : is it possible to easily mix inheritence and templates

简介:C++标准区分依赖模板参数的符号名称和不依赖模板参数的名称,这称为两阶段名称查找(参见here)。定义模板时,会尽快解析非相关名称。另一方面,从属名称仅在模板实例化时解析。示例:templatestructBase{typedefTtype;staticconstintn=3;virtualintf()=0;intf(intx){returnx*2;}};//doesn'tcompile!templatestructDerived:Base{typefield;//Thecompilerdoesn'tknowBase::typeyet!intf(){returnn;}//thec

c++ - SFINAE 优雅地检查 "template template class"(在模板参数中)

如何在模板参数中检查模板模板类的类型?例子B和C是模板类。我想创建一个类D那可以是D或D.只有D有D::f().这是我的解决方法(demo)。它有效。#includeusingnamespacestd;classDummy{};templateclassB{};templateclassC{};templateclassBC>classD{//f()isinstantiatedonlyif"BC"=="B"public:template>statictypenamestd::enable_if>::value,void>::typef(){}//^#1};intmain(){D::f(