草庐IT

is_same_template

全部标签

c++ - _InterlockedCompareExchange 文档中 "The sign is ignored"的含义

_InterlockedCompareExchange的文档对每个参数说Thesignisignored.这是否意味着像0xffff和0x7fff(对于16位版本)这样的数字将被_InterlockedCompareExchange16等视为相等其他宽度内在函数?或者这是否意味着内在函数接受有符号和无符号整数?还是别的?如果这不是文档中的错误,它至少看起来是模棱两可的。 最佳答案 符号位不会被忽略,就像其他位一样进行比较。..CompareExchange..函数只关心位的相等性,不以任何特殊方式解释它们。在基于x86的系统上,它们

c++ - 通用 lambda、重载、std::is_invocable 和 SFINAE - GCC 和 Clang 之间的不同行为

问题我写了一段可以编译的复杂模板代码withGCC8.2.1,但不是withClang7.0(代码和错误链接)。我认为这可能是thisQ&A的暗示,但我看不到它。动机我正在编写一个类,我希望它可以用两个不同类型的可调用对象构造,但也可以省略其中一个,即:my_class(callable_1);my_class(callable_2);my_class(callable_1,callable_2);那应该没有问题。但是,为什么不允许callable_1和callable_2成为函数模板(或带有operator()模板的仿函数)。也就是说,我想要这个(或者至少最初想要):my_class

c++ - 海湾合作委员会 : C++11 inline object initialization (using "this") does not work when there is a virtual inheritance in hierarchy

当在初始化中使用此指针并且在层次结构中存在虚拟继承时,C++11内联对象初始化不起作用(在GCC中)。这可能是GCC的错误吗(因为它在CLang中工作)?还是C++11标准本身的差距?示例(可以在here中尝试),当使用GCC编译以下代码时:FieldIndexm_inB{"inB",this};不会被执行。但它会在使用CLang编译时执行。变通方法:从FieldIndexContainer派生A作为虚拟#include#include#includeusingnamespacestd;classFieldIndexContainer{public:classFieldIndex{pu

c++ - 在模板参数列表中使用 sizeof... 时为 "too few template arguments"(MSVC 2017)

以下最小示例不基于当前的MSVC2017(19.16)。它确实基于MSVC2015和2017(19.14)的旧版本、GCC、Clang和ICC。所以我怀疑这是一个编译器错误。有效吗?如果不是,为什么?#include#includetemplateautofoo(std::integer_sequence){returnstd::array{Is...};}std::arraybar(){returnfoo(std::make_integer_sequence());}有效的变体:投入unsigned(sizeof...(Is))在参数列表中作为默认参数替换unsigned(...)与

C++ 微软 : How to associate uuid/guid with template specialization

我想将uuid/guid与模板特化相关联。以下代码可用于将uuid与非模板接口(interface)(类、结构)相关联:__interface__declspec(uuid("CECA446F-2BE6-4AAC-A117-E395F27DF1F8"))ITest{virtualvoidTest()=0;};GUIDguid=__uuidof(ITest);//OK现在我有了一个模板化的界面template__interfaceITemplateTest{virtualvoidTest(Tt)=0;};我想做以下工作:GUIDtemplateGuid=__uuidof(ITemplat

c++ - 如何在 C++ 中避免 "template template template"模板

我已经尝试实现一个“模板模板模板”——模板类来满足我的需求(我对使用模板元编程很陌生)。不幸的是,我发现以下主题为时已晚:TemplateTemplateParameters不过,我需要实现如下所列的内容。根据编译器,最后一个typedef不工作。我不确定,但我认为这是由于3x模板限制的限制。在这个简单的示例中是否有可能绕过3xtemplate定义?templateclassITTranslator{public:ITTranslator()=0;virtual~ITTranslator()=0;virtualvoiddoSomething()=0;}templateclassTCon

c++ - 为什么我收到错误 "non-template ' f' used as template”

我正在尝试了解在哪里使用template和typename我遇到了一个我无法完全解决的问题。我有一个模板函数f它使用传递给它的类型(将是一个类)来调用模板成员函数.f.我想我使用typename在函数体中是正确的,但是,我不断收到以下错误:source.cpp:Infunction'voidf()':source.cpp:11:19:error:non-template'f'usedastemplatesource.cpp:11:19:note:use'typenameT::C::templatef'toindicatethatitisatemplatestructA{structC{

c++ - 窗体头文件中的 "error C2653: System is not a class or a namespace name",Visual C++

我之前关于同一项目的问题:one和two.没有必要阅读它们;只知道我正在尝试在VisualC++项目中使用nativeC++SDK。这比我最初想象的要棘手得多,但是这个网站关于ExtendinganativeC++projectwithmanagedcode已经帮助了我很多。按照最后一个链接的说明,我已将一个表单添加到我的nativeC++项目中,该项目已自动将项目转换为CLR项目。只有MainForm.cpp和Interface.cpp(允许nativeC++代码创建和显示MainForm的文件)使用/clr编译旗虽然;其他文件保持原样。我现在遇到的问题是,VisualStudio似

c++ - 英特尔编译器 - 错误 : identifier "alignof" is undefined

我正在尝试运行alignof运算符的示例。#includestructEmpty{};structFoo{intf2;floatf1;charc;};intmain(){std::cout当我用gcc(g++-std=c++11alignof.cpp)编译它时,我没有得到任何错误。但是当我用icc(icpc-std=c++11alignof.cpp)编译它时,我得到以下错误,我不知道为什么:cenas.cpp(13):error:typenameisnotallowedstd::cout我在同一台机器上运行代码,并使用module命令更改编译器。alignof运算符怎么可能未定义?

c++ - OpenCV 错误 : Sizes of input arguments do not match (The operation is neither 'array op array' )

我正在做一个在树莓派上使用opencv的项目。我遇到了一个看起来很简单的障碍,但我无法解决问题。首先,这是我的代码的一部分:{gray=cvarrToMat(py);///cvShowImage("camcvWin",py);//displayonlygraychannelif(img_num%2==1){cv::imwrite("/home/pi/test/Gray_2Image1.jpg",gray);}elseif(img_num%2==0){cv::imwrite("/home/pi/test/Gray_2Image2.jpg",gray);cv::Matimg2=cv::im