草庐IT

e-implicitly-typed-declarations-p

全部标签

c++ - 如何将 "point of declaration"解释为 "const int i=2; { int i[i]; }"- C++ 标准中的示例?

我正在研究C++标准以了解操作顺序、表达式、语句和副作用。一个相关的问题是名称的“声明点”。在C++11标准的§3.3.2.1节中,该标准规定:Thepointofdeclarationforanameisimmediatelyafteritscompletedeclarator(Clause8)andbeforeitsinitializer(ifany)...以下段落添加了带有示例的注释:Note:anamefromanouterscoperemainsvisibleuptothepointofdeclarationofthenamethathidesit.……举个例子constin

c++ - 我可以在 vector 的一个实例上使用 value_type,而不是它的类型吗

在播放和尝试计算vector的总大小时,我尝试了类似的方法vectorvd;autoarea=vd.size()*sizeof(vd::value_type);//IveseenStepanovuseareaasnameforthiskindofsize,idkifheaddsthesizeofvdalsotoarea:)不幸的是,这不起作用......我需要使用vector::value_type但这会降低代码的可读性。它可以工作吗?我不喜欢sizeofvd.front()因为写front()看起来很难看为此。编辑:decltype变体也适合我所说的丑陋类别......

c++ - 容器模板参数的 value_type

在他今年GoingNative的主题演讲中TheEssenceofC++(转到40:30)BjarneStroustrup给出了以下代码示例:templatevector*>find_all(C&cont,Vv){vector*>res;for(auto&x:cont)if(x==v)res.push_back(&x)returnres;}此函数用于查找容器中所有出现的值并返回指向找到的元素的指针。视频中的示例:stringm{"Maryhadalittlelamb"};for(constautop:find_all(m,'a'))//pisachar*if(*p!='a')cerr我

c++ - 将深拷贝构造函数添加到 std::unique_ptr<my_type>

我想存储一些std::unique_ptr进入std::vector.自my_type提供一个clone()制作my_type*的深拷贝非常简单.重点是如何扩展std::unique_ptr在添加复制构造函数和赋值运算符的同时保留其所有功能。遗产?模板特化?你能提供一个代码片段吗? 最佳答案 std::unique_ptr的目的是使其唯一,即它不应该是可复制的。这就是为什么他们将其设为只能移动的原因。它用于表示唯一所有权。如果你想做一个深拷贝然后让你的拷贝构造函数完成它的工作,这就是它的用途。std::unique_ptrptr1{

C++ 错误 : ‘_mm_sin_ps’ was not declared in this scope

我正在尝试对将函数应用于数组的不同方法进行基准测试。为什么是https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=3260,2124,4779,4779&cats=Trigonometry&text=_sin_mm_sin_ps在我的范围内未知,但_mm_sqrt_ps是?我如何让它为人所知?并编译无误。#include#include#include#include#include#include#include"immintrin.h"#includeintmain(){std::coutdis(-

c++ - 枚举 "does not name a type' 的问题

g++(Ubuntu/Linaro4.4.4-14ubuntu5)4.4.5我有一个问题,我似乎找到了我得到这个错误的方法。文件statemachine.h#ifndefSTATEMACHINE_H_INCLUDED#defineSTATEMACHINE_H_INCLUDED#include"port.h"enumstate{ST_UNINITIALIZED=0x01,ST_INITIALIZED=0x02,ST_OPENED=0x03,ST_UNBLOCKED=0x04,ST_DISPOSED=0x05};voidstate_machine(eventevt,port_t*port)

C++ 标准 : default "const T& value" in vector constructor for type 'int'

explicitvector(size_typen,constT&value=T(),constAllocator&=Allocator());vectorvec(10);cout::const_iteratoriter=vec.begin();iter!=vec.end();++iter){coutVS2010的输出:vec.size:100000000000问题>:根据最新的C++标准,当我们使用vectorObject(size_type)定义一个vector对象时,默认的int值是多少?在这里你可以看到,VS2010输出0作为默认的int值。但我不知道这是否是C++标准所要求的

RabbitMQ(十二)Cannot deserialize value of type `java.lang.String` from Object value 报错整理

目录1.核心报错内容:2.完整报错内容:3.报错原因:4.解决方案:消息接收类型错误1.核心报错内容:Cannotdeserializevalueoftypejava.lang.StringfromObjectvalue(tokenJsonToken.START_OBJECT)2.完整报错内容:org.springframework.amqp.rabbit.listener.exception.FatalListenerExecutionException:Illegalnullidinmessage.Failedtomanageretryformessage:(Body:'[B@7f8bf9

c++ - 错误 : ambiguates old declaration ‘double round(double)’

/usr/include/i386-linux-gnu/bits/mathcalls.h:311:1:error:ambiguatesolddeclaration‘doubleround(double)’g.cpp:Infunction‘intround(double)’:g.cpp:14:24:error:newdeclaration‘intround(double)’/usr/include/i386-linux-gnu/bits/mathcalls.h:311:1:error:ambiguatesolddeclaration‘doubleround(double)’#includ

c++ - std::vector<T>::value_type 的正确行为

在对一些使用std::vector::value_type的模板代码中的一些错误摸不着头脑之后,我追踪到了以下内容。这是符合标准的正确行为,还是MSVC2012CTP的问题?typedefstd::vector::value_typet1;typedefstd::vector::value_typet2;static_assert(!std::is_same::value,"hmmm");上述断言失败。 最佳答案 value_type的std::vector是T(§23.3.6.1)。is_same的值将简历限定符考虑在内(§20.