草庐IT

implicit-function-declaration

全部标签

c++ - "structured bindings"与 "decomposition declarations"

观察:在P0217R3proposal(2016-06-24),使用了结构化绑定(bind)术语。在currentworkingC++1zdraft(2016-11-28),使用了分解声明术语。在P0615R0proposal(2017-03-01),分解声明被重命名为结构化绑定(bind)。引人注目,thisblogpost(2017-01-09)包含以下文本:Decompositiondeclarations.[..]Wasoriginallycalled"structuredbindings".同样,thisquestion(2017-03-04)包含以下文本:[..]C++17

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++ 错误 : ‘_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++ - "more than one instance of overloaded function "标准::战俘 "matches the argument list"

使用C++,我尝试#defineTINYstd::pow(10,-10)我为定义了TINY的类(.h)提供了带有#include和命名空间信息的代码#pragmaonce#include"MMath.h"#include#include#includeusingnamespacestd;#defineTINYstd::pow(10,-10)我在.cpp文件中的一些函数实现中使用了TINY,而TINY给出了错误IntelliSense:morethanoneinstanceofoverloadedfunction"std::pow"matchestheargumentlist什么是正确的

C++ 设计 : functions with boolean options

我有一个关于C++中“良好设计实践”的问题。我正在用C++11编写一个数字库,我使用了很多元编程和基于模板的技术。但我有一个非常基本的问题:考虑一个函数,它可以有两个非常接近的行为,除了一个可以由boolean标志激活的选项。我只考虑一个可以由开发人员设置/取消设置的标志,而不是一个可以在运行时设置/取消设置的标志。设计有3种可能性:1)编写两个在名称中带有显式选项的函数:myFunctionFlag1(...);myFunctionFlag2(...);2)使用模板参数:templatemyFunction(...);3)使用可变参数:myFunction(...,constbool

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++ - 创建一个带有任何签名的 "do-nothing" `std::function`?

我想创建一个带有任意签名的简单无操作std::function对象。为此,我创建了两个函数:templatestd::functionGetFuncNoOp(){//The"default-initialize-and-return"lambdareturn[](ArgsProto...)->RESULT{return{};};}templatestd::functionGetFuncNoOp(){//The"do-nothing"lambdareturn[](ArgsProto...)->void{};}其中每一项都运行良好(显然,第一个版本可能会在RESULT对象中创建未初始化的数

c++ - 在 C++ 中 : why does a constructor get called when an array of objects is declared?

MyClassmc2[]={MyClass(),MyClass()};//thiscallstheconstructortwiceMyClassmc1[4];//thiscallstheconstructor4times.Why?所以,我的问题是:为什么没有初始化的对象数组声明会导致调用默认构造函数? 最佳答案 在C++中,大小为4的MyClass数组是四个实际对象。它有点像包含该类型的四个成员的结构,当然您可以使用不同的语法访问这些成员,并且存在其他技术差异。因此,定义该数组导致构建4个对象的原因(并且在大致相同的情况下)与定义该

c++ - 警告 : function uses 'auto' type specifier without trailing return type

下面的代码给出了下面的警告。有人可以解释原因吗(请注意代码没有用,因为我用int替换了我的类型来制作一个完整的示例)。警告:“MaxEventSize()”函数使用“auto”类型说明符而没有尾随返回类型[默认启用]想法是获取特定结构的最大大小(类型位于int所在的位置)。templateconstexprTcexMax(Ta,Tb){return(a 最佳答案 auto返回类型“没有尾随返回类型”是C++14的一个特性,所以我想你正在编译C++11。您的代码适用于C++14,但对于C++11,如果您想使用auto作为返回类型,您需

C++ 错误 : definition of implicitly-declared

我正在用C++编写这个链表程序当我测试程序时,我得到了错误linkedlist.cpp:5:24:error:definitionofimplicitly-declared'constexprLinkedList::LinkedList()'LinkedList::LinkedList(){这是代码链表.h文件:#include"node.h"usingnamespacestd;classLinkedList{Node*head=nullptr;intlength=0;public:voidadd(int);boolremove(int);intfind(int);intcount(i