草庐IT

Char_Type

全部标签

c++ - 无法在 VS 14 CTP : conditional expression of type 'void' is illegal 中使用 auto 声明 lambda

使用VisualStudio2014CTP、C++(v140)编译器:autogp=[&](BYTE*buff){autogp1=[](char*bff,char**p1){*p1=strstr((char*)bff,"(");return(*p1);};};错误:conditionalexpressionoftype'void'isillegal(也许auto真的输入错误?)如果我将内部lambda声明为std::functiongp1然后就可以了是我做错了什么还是编译器错误? 最佳答案 我没有运行2014,但您可能需要指定内部l

c++ - 使用前向声明时如何修复 "field has incomplete type"错误

如注释中所述,此代码抛出编译器错误error:field‘fTarget’hasincompletetype。为什么会这样?我只是分配那个字段而不做任何需要知道里面是什么的操作......或者我是?也许它无法弄清楚复制构造函数?classFSRVertex;//fwdclassFSREdge{public:charfC;FSRVertexfTarget;//compilererrorFSREdge(charc,FSRVertextarget):fC(c),fTarget(target){}//compilererror};classFSRVertex{public:boost::uno

c++ - 为什么 UuidFromString 函数请求非常量指针指向 unsigned char?

我不知道为什么UuidFromString函数需要非常量指向无符号字符的指针。为什么不用constchar*代替呢?我的想法是不需要修改第一个参数所指出的数据。 最佳答案 UuidFromString专为COM/DCOM而设计。unsignedchar是为了防止需要检查负数char值(默认char是signed,这意味着值的范围是[-128,127]-因为这个字符串应该是ANSI字符,这是避免条件检查的一种廉价方法)。它的姊妹函数(UuidToString)确实需要一个const输入参数。我在文档中看不到关于为什么UuidFromS

c++ - 错误 C2893 : Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Types &&...) noexcept(<expr>)'

下面是一个给出编译时错误的程序。这主要与D类中的Boo函数有关。我最终尝试使用多个线程来调用solve方法,但目前这对我来说似乎不太有效,无法做到这一点。错误是:1>d:\dummy\project1\trash.cpp(37):warningC4101:'d':unreferencedlocalvariable1>c:\programfiles(x86)\microsoftvisualstudio\2017\community1\vc\tools\msvc\14.11.25503\include\thr\xthread(240):errorC2672:'std::invoke':no

c++ - const char[] 默认函数参数

我定义了这样一个类型:typedefcharsType[256];和一个带有默认参数的函数:voidfoo(constsTypeparam=NULL);MinGW(g++4.8.0)编译它没有错误。相反,VisualStudio2015(Tools14.0)给出了以下错误:errorC2040:'sType':'int'differsinlevelsofindirectionfrom'char[256]'我试图将NULL转换为constchar[],但这会导致:errorC2440:'typecast':cannotconvertfrom'int'to'constchar[]'有什么提

c++ - std::vector 应该尊重 alignof(value_type) 吗?

如果我定义一个具有特定对齐要求的简单类型,该类型的std::vector难道不应该为每个元素遵守对齐吗?考虑下面的例子typedefstd::arrayalignas(32)avx_point;std::vectorx(10);assert(!(std::ptrdiff_t(&(x[0]))&31)&&//assertthatx[0]is32-bytealigned!(std::ptrdiff_t(&(x[1]))&31));//assertthatx[1]is32-bytealigned我发现clang3.2(带或不带-stdlib=libc++)悄悄地(没有任何警告)违反了对齐要求

c++ - 振奋 spirit : What type names should be used for the built in terminals?

我正在重构一个类型系统(类型模型),它使用spirit进行字符串序列化。我正在使用类型特征的编译时建模构造。templatetype_traits{typedefboost::spirit::qi::int_parserstring_parser;}templatetype_traits{typedefboost::spirit::ascii::stringstring_parser;}在这个例子中,我展示了原始解析器,但我希望也加入规则。int4类型有效,但这是因为(home/qi/numeric/int.hpp+27):namespacetag{templatestructint_

c++ - 将 python 列表包装为 unsigned char*

编辑:大家好!!我目前正在尝试从Python访问C++函数,当我尝试将Python列表作为参数传递给函数时遇到了问题。这是我试图访问的C++函数定义(用于向PC/SC阅读器发送命令):SRpdu*SendAPDU(unsignedintuiAPDU,//CommandunsignedintucLE,//DataexpectedforresponseunsignedintucLC,//Sizeofdatabufferunsignedchar*pucDataBuf=0);//databuffer我的目标是像下面的示例一样从python调用此函数。目标是将列表[1,2,3]转换为unsign

c++ - 使用 char 参数从 <cctype> 调用函数是否安全?

C编程语言表示来自的函数遵循一个共同的要求:ISOC99,7.4p1:Inallcasestheargumentisanint,thevalueofwhichshallberepresentableasanunsignedcharorshallequalthevalueofthemacroEOF.Iftheargumenthasanyothervalue,thebehaviorisundefined.这意味着下面的代码是不安全的:intupper(constchar*s,size_tindex){returntoupper(s[index]);}如果此代码在char的实现上执行与sig

c++ - 通过指针获取: good practice?装饰一个char*和char const*

你好,我想就我做一个字符串类(如std::string)的想法向公众进行投票,该字符串类具有能够在客户端提供的缓冲区上工作的特性。您预见到的危险是什么?是经典的味道吗?等等我的意思是:charext[64]={0};my::strings(ext,my::string::acquire_RW);size_tlen=s.size();size_tpos=s.find("zboub");my::strings2(s);//usestrue(alloc+)copysemantichere.所以我预见了2种策略:acquire_RW和acquire_RO将允许或不允许修改ext中的字符。在RO