草庐IT

TEMPLATE_DEBUG

全部标签

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(

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++ - "typename"和 "template"关键字 : are they really necessary?

编译c++模板代码时,这个站点上有很多问题。此类问题最常见的解决方案之一是在程序代码的正确位置添加typename(以及不太常见的template)关键字:templateclassBase{public:typedefcharSomeType;templatevoidSomeMethod(SomeType&v){//...}};templateclassDerived:publicBase{public:voidMethod(){typenameBase::SomeTypex;//^^^^^^^^this->templateSomeMethod(x);//^^^^^^^^}};是否有

c++ - fatal error LNK1104 : cannot open file "Debug/

我正在尝试在MicrosoftVisual6.0版中运行C++代码。代码编译良好,但我收到错误“fatalerrorLNK1104:当我尝试构建时无法打开文件“Debug/Assignment.exe”。该文件保存在名为Assignment的项目中。我是C++的新手,并且微软视觉的东西。我不知道从哪里开始绕过错误。请帮助。 最佳答案 听起来exe(Debug/Assignment.exe)的拷贝已经在运行,因此visualstudio无法覆盖该文件。查看任务管理器/进程资源管理器并终止所有正在运行的拷贝,然后重试。

C++ 模板 : cannot match the last template in variadic class template

我正在学习C++11可变参数模板并创建了一个模板结构来计算给定列表的最大数量并尝试了:#include#includetemplatestructmax:std::integral_constantb?max::value:max::value)>{};templatestructmax:std::integral_constantb?max::value:max::value)>{};templatestructmax:std::integral_constant{};intmain(){std::cout::value但是g++提示:test.cc:7:58:error:wrong

c++ - 外部 "C"DLL : Debug is OK, 发布抛出错误 C2059

我有一个作为C++Win32应用程序创建的DLL。为了防止在我的DLL中出现名称混淆,我使用了下面定义的EXPORT定义:#ifndefEXPORT#defineEXPORTextern"C"__declspec(dllexport)#endifEXPORTint_stdcallSteadyFor(doublePar[],doubleInlet[],doubleOutlet[]);为了编译这段代码,我必须进入项目的属性并将C/C++CallingConvention设置为__stdcall(/Gz)并设置CompileAs到CompileasC++Code(/TP)。这在Debug模式

c++ - g++ 可变参数模板。简单示例代码无法编译,提示 'Not a template'

我正在探索这个陌生的领域,并想尝试来自DannyKalev'stutorialonthematter的一个简单示例.代码非常简单:templatestructCount{staticconstintvalue=0;};templatestructCount//partialspecialization{staticconstintvalue=1+Count::value;};但是gcc4.4.7甚至4.7.0提示(尽管-std=c++0x-std=gnu++0x标志):/src/tests/VTemplates.h:12:8:error:'Count'isnotatemplate/sr

c++ - 错误 C2899 : typename cannot be used outside a template declaration

我正在MSV2010中尝试以下内容namespacestatismo{templatestructRepresenterTraits,3u>>{typedefitk::Image,3u>VectorImageType;typedefVectorImageType::PointerDatasetPointerType;typedefVectorImageType::PointerDatasetConstPointerType;typedeftypenameVectorImageType::PointTypePointType;typedeftypenameVectorImageType:

一个Vivado仿真问题的debug

我最近在看Synopsys的MPHY仿真代码,想以此为参考写个能实现PWM-G1功能的MPHY,并应用于ProFPGA原型验证平台。我从中抽取了一部分代码,用Vivado自带的仿真器进行仿真,然后就遇到了一个莫名其妙的问题,谨以此文作为debug记录。一、原始问题涉及到的相关代码如下:第一张图是我从MPHY仿真代码里copy的一个task,用于对MPHY进行参数配置;第二张图是我要配置的MPHY参数;第三张图是选取的一个出问题的参数模块例化;第四张图是这个参数模块的实现,非常简单。就是这么简单的几行代码,却意外出问题了,仿真波形如下图所示,可以看到参数没有配置成功。我真的是百思不得其解,就用了

c++ - 如何编写仅在 DEBUG 为#defined 时才编译的 'if' 条件?

我需要一些帮助来为“if-condition”编写宏,该宏仅在#define指令定义了DEBUG标志时才编译。这是一个说明我想要的例子。第一段代码显示了使用#ifdef编写if条件的常用方法。#ifdefDEBUGif(rv==false){stringerrorStr="errorinreturnvalue";cout我想像下面这样写:DEBUG_IF(rv==false){samecodeasabove}这看起来很简单,但我在定义可以执行此操作的宏时遇到了问题。如果有人以前遇到过这种情况,请提供帮助。谢谢。 最佳答案 尝试:#i