草庐IT

declare_namespace

全部标签

c++ - 在 namespace 内的 lambda 中使用时找不到运算符重载

以下不编译(使用Clang5.0.0/gcc7.3,std:C++11):Clang中的错误信息:错误:二进制表达式的无效操作数(std::vector>和std::vector>)#include#includenamespacens{usingMyType=std::vector;}//namespacensusingns::MyType;MyType&operator+=(MyType&lhs,constMyType&rhs){for(inti=0;i;Funcoperator+(constFunc&lhs,constFunc&rhs){return[lhs,rhs](){aut

c++ - namespace 别名是否会更改链接?

根据我的理解,.cpp文件中的全局变量得到外部链接。假设有两个源文件,a.cpp和b.cpp://a.cppnamespacea_ns{intfoo;}//b.cppnamespaceb_ns{intfoo;}现在假设两者都在namespacens=a_ns;和namespacens=b_ns;之后。如果a.cpp和b.cpp都使用相同的命名空间ns,这会触发任何未定义的行为吗(我认为)对于foo? 最佳答案 没有。您建议的别名不会改变变量具有限定名称a_ns::foo和b_ns::foo的事实,它们是不同的。

c++ - 如何使用外部链接在 namespace 范围内定义常量 double?

我正在尝试创建一个带有外部链接的命名空间范围常量//insomeincludefile:namespacefoo{constexprdoublebar(){return1.23456;}//internallinkageconstexprdoublebaz=1.23456;//internallinkageconstdoublebing=1.23456;//internallinkage}这可能吗? 最佳答案 是,也不是;你可以使用extern:[C++11:3.5/3]:Anamehavingnamespacescope(3.3.

c++ - "Function not declared in this scope"编译openCV代码出错

我正在尝试编写一些使用openCV函数的代码。我从文档中提供的一些示例代码开始:#include#include#includeusingnamespacecv;usingnamespacestd;intmain(intargc,char**argv){if(argc!=2){cout当我尝试在Eclipse-CDT中构建它时,我得到了这个:****BuildofconfigurationDebugforprojectopenCV1****makeallBuildingtarget:openCV1Invoking:CrossG++Linkerg++-L/usr/local/lib-o"

c++ - 将类放入 namespace

我看到Qt在Ui界面中放置了一个类,如下所示:namespaceUi{classMainWindow;}classMainWindow:publicQMainWindow{...这种方法是否等同于将整个类封闭在命名空间中?它看起来确实更干净。 最佳答案 不,在您的示例中,Ui::MainWindow是与全局命名空间中定义的MainWindow类不同的类。看:namespaceUi{classMainWindow;}classMainWindow{};intmain(){Ui::MainWindowmw;//failsduetoinc

c++ - g++ "declaration of "运算符<<"as non-function"

我们有一个自定义的Logging类,它在VisualStudio2010中编译良好,但在Linux上使用g++编译时会抛出错误。我们收到的错误消息如下:Logger.hpp:84:error:declarationof"operator各自的代码行如下:/*:84*/inlineLogger&operatoroutput){if(this->loggingEnabled())std::coutoutput){if(this->loggingEnabled())std::cout>&(*StdEndl)(std::basic_ostream>&);inlineLogger&operato

c++ - 错误 C2899 : typename cannot be used outside a template declaration

我正在MSV2010中尝试以下内容namespacestatismo{templatestructRepresenterTraits,3u>>{typedefitk::Image,3u>VectorImageType;typedefVectorImageType::PointerDatasetPointerType;typedefVectorImageType::PointerDatasetConstPointerType;typedeftypenameVectorImageType::PointTypePointType;typedeftypenameVectorImageType:

c++ - '简历' : a namespace with this name does not exist while building (VS 2015, OpenCV 3.2)

在VS2015中构建一个简单的OpenCV应用程序时出现错误'cv':anamespacewiththisnamedoesnotexistwhilebuilding虽然我相信我已经完成了为VS配置OpenCV所需的所有步骤(使用本文作为引用http://opencv-srf.blogspot.com/2013/05/installing-configuring-opencv-with-vs.html)类(class)的开始很简单#include"opencv2/imgcodecs.hpp"#include"opencv2/highgui.hpp"#include"opencv2/sti

c++ - caffe 安装 : gcc error namespace "std" has no member "isnan"

我正在尝试安装(py)caffe在ubuntu17.10上然而,当我执行makeall时,出现以下错误:./include/caffe/common.hpp(84):error:namespace"std"hasnomember"isnan"./include/caffe/common.hpp(85):error:namespace"std"hasnomember"isinf"2errorsdetectedinthecompilationof"/tmp/tmpxft_00004921_00000000-19_nesterov_solver.compute_61.cpp1.ii".Mak

c++ - (C++) 错误 : 'invalid_argument' was not declared in this scope

我正在使用EclipseC/C++和MinGW编译器。我已将标志-std=c++11添加到项目属性中C/C++Build下的MiscellaneousGCCCCompilerSettings中。我知道这可能是一件简单的事情,但我无法解决此错误。Date.h#includeusingnamespacestd;classDate{public:Date(intm=1,intd=1,inty=1900);voidsetDate(int,int,int);private:intmonth;intday;intyear;staticconstintdays[];};日期.cpp#include#