草庐IT

is_constexpr_copiable

全部标签

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++ - 在 C++ 中同一类的另一个方法中使用 constexpr 方法

不出所料,我可以毫无问题地编译下面的示例//first_sample.cppstructsample_struct{constexprintsample_method(){return5;}};intmain(){sample_structsample_object;constexprintsample_variable=sample_object.sample_method();return0;}但由于以下原因我无法编译以下示例'this'isnotaconstantexpression//second_sample.cppstructsample_struct{constexpri

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

c++ - 如何解释 is_assignable 中的 declval<_Dest>() = declval<_Src>()

我想弄清楚如何在is_assignable的实现中解释declval()=declval()。declval将类型转换为引用。鉴于此,我将表达式转换为以下四种可能性之一:_Dest&&=_Src&&_Dest&&=_Src&_Dest&=_Src&&_Dest&=_Src&然后我创建了两个辅助函数。templateTrvalue();templateT&lvalue();我的理解是这四个表达式可以用模板函数实现。_Dest&&=_Src&&----->右值()=右值()其他三个也是一样。然后我通过编译三对具体类型的每种可能性的模板函数版本来模拟decltype(declval()=de

c++ - 不接受静态成员函数作为 constexpr 参数

以下代码被clang接受并被gcc拒绝。我想知道这是一个错误还是我遗漏了什么:#includetemplatestaticconstexprTApply(Tin,Tfun(T)){returnfun(in);}templatestructTriangle{usingAr=std::array;staticconstexprArfoo(Arline){returnline;}staticconstexprArresults=Apply({{1}},foo);//foo({1});isok};templateconstexprstd::arrayTriangle::results;intm

c++ - std::is_class 的实现

我想知道std::is_class(http://www.cplusplus.com/reference/type_traits/is_class/)是如何实际实现的。我查看了/usr/include/c++/4.8/tr1/type_traits但似乎唯一存在的是:///is_classtemplatestructis_class:publicintegral_constant{};__is_class的定义在任何地方都找不到(或者我只是看得不够深入)。无论如何,如果有人能指出我在哪里寻找这个(以及std命名空间中的其他is_***),我会很高兴 最佳答案

c++ - 在 Visual Studio 中构建解决方案时出现 "Unable to create directory"错误 "Access to path is denied."

我正在尝试在VS2013中构建一个VS2010C++项目(准确地说,是来自SteinbergVstSDK的示例项目)并出现以下错误:C:\ProgramFiles(x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(1235,5):errorMSB3191:Unabletocreatedirectory"C:\ProgramFiles(x86)\CommonFiles\VST3\Steinberg".Accesstothepath'C:\ProgramFiles(x86)\CommonFiles\VST3\St

c++ - 非成员函数 begin()/cbegin() 及其constexpr-ness

C++11引入了没有constexpr-说明符的std::begin()非成员函数,然后C++14更新为constexpr-std::begin()用于数组类型(T(&)[N])并附加constexpr-std::cbegin()用于通用容器类型(constC&).引自http://en.cppreference.com/w/cpp/iterator/begintemplateconstexprT*begin(T(&array)[N]);//(sinceC++14)templateconstexprautocbegin(constC&c)->decltype(std::begin(c)

c++ - 允许这种派生到基础转换的理由是什么(当它似乎违反 IS-A 时)?

我用来快速确定派生到基础的转换是否合法的规则是检查在转换的上下文中,derived是否是一个base(即,derived提供对base的公共(public)API的访问)。它在C++Primer(第5版)中更好地表述为:Foranygivenpointinyourcode,ifapublicmemberofthebaseclasswouldbeaccessible,thenthederived-to-baseconversionisalsoaccessible,andnototherwise.现在让我们想象一个类层次结构如下:classBase{public:intmem;};clas