草庐IT

project-template

全部标签

c++ - 错误 : C2988: unrecognizable template declaration/definition

我的两个模板的标题中出现错误。两者都有类似的声明和定义如下:templatevoidsetVideoCodecOption(T1AVCodecContext::*option,T2(CR2CVideoCodecSettings::*f)()const);templatevoidEncoderPrivate::setVideoCodecOption(T1AVCodecContext::*option,(CR2CVideoCodecSettings::*f)()const){T2value=(m_videoSettings.*f)();if(value!=-1){m_videoCodecC

c++ - eclipse CDT : How to manage multiple main() functions in a single C++ project?

我正在开始开发一个由多个模块组成的项目。我将使用专用的测试台验证这些模块中的每一个,每个模块都有它们的main()函数。我想避免为每个测试平台及其main()函数创建一个Eclipse项目。我读到了WorkingSets在我的项目中只显示与特定测试平台相关的文件的想法正是我所寻找的。但是,在构建阶段,Eclipse会继续构建所有项目文件,而不仅仅是当前的工作集文件。然后,由于多个main()函数,我遇到了链接器错误。如何将Eclipse配置为仅构建工作集的文件?是否有另一种方法可以在单个项目中分别构建多个程序,即应用程序及其组件测试平台? 最佳答案

c++ - 模板特化站点报告 "too few template-parameter-lists"错误

代码某处有错误,但我不知道如何解决。它说“模板参数列表太少”。我不明白哪个是错误的。代码如下:#if!defined(VECTOR_H_INCLUDED)#defineVECTOR_H_INCLUDED#include//forsize_tnamespaceVec{classVector_base{public:explicitVector_base(){}};templateclassVector:publicVector_base{typedefVectorME;explicitVector(T,T,T);doubledot(constME&v)const;T&operator[]

C++1y/14 : auto variable templates?

下面的C++1y/C++14程序格式错误吗?templateconstexprautoX=42;intmain(){static_assert(X==42,"");}为什么/为什么不?Clangtrunk提示说:error:invalidoperandstobinaryexpression('auto'and'int') 最佳答案 这是clang中的一个错误,现在已修复:http://llvm.org/bugs/show_bug.cgi?id=19152 关于C++1y/14:autov

c++ - Visual Studio 2017 : ambiguous symbol size_t in linux projects

在VisualStudio2017中创建Linux项目并在源代码中插入usingnamespacestd;时,如下所示:#include#includeusingnamespacestd;intmain(){size_ti=1;strings=to_string(i);coutVS下划线size_t说是有歧义的符号。如果我按F12(转到定义),它会为我提供两个定义位置:来自stddef.h(C:\ProgramFiles(x86)\MicrosoftVisualStudio14.0\VC\Linux\include\usr\include\x86_64-linux-gnu\5\incl

c++ - std::map 和 -fno-implicit-templates

我正在尝试使用g++4.4进行编译并链接一个使用STL的简单程序。我正在尝试使用-fno-implicit-templates来做到这一点,因此必须显式实例化所有模板。我不明白为什么此代码有效:#include//templateclassstd::map;templateclassstd::_Rb_tree,std::_Select1st>,std::less,std::allocator>>;intmain(){std::maptable;return0;}我希望这个程序需要这一行:templateclassstd::map;,但是该行不会使程序链接。std::_Rb_treeli

C++:专门化成员需要 «template<>» 语法

我做错了什么?templateclassBinder{public:staticstd::vector*>all;Node*from;Node*to;Binder(Node*fnode,Node*tonode){from=fnode;to=tonode;Binder::all.push_back(this);}};std::vector*>Binder::all=std::vector*>();//hereitis谢谢。 最佳答案 静态成员的定义被编译器解释为一个特化(实际上,它是一个特化:你给出了一个特定于T=int的声明)。这可

c++ - template-parameter-list of template parameter 是什么意思

引用3.3.9/1中的一句话:Thedeclarativeregionofthenameofatemplateparameterofatemplatetemplate-parameteristhesmallesttemplate-parameter-listinwhichthenamewasintroduced.你能举个例子来理解上面的定义吗?我也想知道模板参数的模板参数列表是什么意思?示例会有所帮助。 最佳答案 template//thedeclarativeregionendshereclassq//hencethenamema

c++ - 如何将 `std::array` 用作 `template<typename> class` 形式的模板参数?

请考虑以下tree类templateclassTuple>classtree{private:Tm_value;Tuplem_children;};templateusingstatic_tree=tree>;定义不明确。std::array不是Tuple的合适模板参数.我假设static_tree的意图清楚了。我们可以做类似的事情templatestructhelper{templateusingtype=std::array;};templateusingstatic_tree=tree::templatetype>;没有helper还有其他选择吗?类(class)?

c++ - 什么是 "template<class T> using owner = T;"?

以下摘自Microsoft的gsl库(https://github.com/microsoft/gsl)的gsl.h:namespacegsl{////GSL.owner:ownershippointers//usingstd::unique_ptr;usingstd::shared_ptr;templateusingowner=T;...};我无法理解以下别名模板的含义:templateusingowner=T;有什么解释吗? 最佳答案 这意味着对于每个T,owner是T的别名. 关于