草庐IT

get_template_args_count

全部标签

c++ - 错误 : ‘template<class> class std::auto_ptr’ is deprecated

我正在使用scons和ubuntu。当我使用'scons'制作一些程序时,会发生错误,例如,src/db/DBTextLoader.cc:296:3:error:‘templateclassstd::auto_ptr’isdeprecated[-Werror=deprecated-declarations]/usr/include/c++/5/bits/unique_ptr.h:49:28:note:declaredheretemplateclassauto_ptr;这是我的命令;$./configuer$sourcesomething.sh$scons其实我也不知道。我已经在搜索这个

c++ - 如何让非成员 get<N> 为命名空间中的自定义类工作 [C++17]

C++17引入了结构化绑定(bind)声明:auto[a,b]=some_tuple;.这对于像std::tuple这样的东西是开箱即用的。也可以使其适用于自定义类型,您只需提供(除其他事项外)一个get-function模板,作为成员或在自定义类之外。对于标准类,这是通过位于标准命名空间中的非成员获取完成的:autoa=std::get(some_tuple);有效,但无效autoa=some_tuple.get();.但这里对我来说很奇怪:因为我们必须显式地为get指定模板参数N,所以ADL不起作用,例如,我们不能只写autoa=get(some_tuple);.但是随后带有元组的

c++ - 错误 : Expected template-name before '<' token

我正在尝试编译一个实现chain和chainNodes的程序并在以下行(第22行)出现错误:classchain:publiclinearList错误是:Error:expectedtemplate-namebefore'知道为什么会出现这种情况吗?我的代码如下://linkedimplementationofalinearlist//derivesfromabstractclasslinearListjusttomakesure//allmethodsoftheADTareimplemented#ifndefchain_#definechain_#include#include#in

C++11 : Is it possible to give fixed-template-parameted template to varidic-template-template-parameter?

(是的,由于我糟糕的英语,标题很奇怪;我希望有人能改进它。)接听thisquestion,我发现这段代码有效:templateclassA{};templateclassU>classB{};intmain(){Bit_works;}..虽然templateclass和templateclass不相等。我试图弄清楚为什么这是可能的,并观察了N3337standard的[temp.param],但我找不到任何东西。怎么可能? 最佳答案 是的,这是可能的。C++1114.3.3/3特别允许,并提供了一个例子。3Atemplate-arg

c++ - 为什么 std::map 有一个名为 count 的成员函数?

这个问题在这里已经有了答案:WhydoesSTLsethavecount()whenallelementsaresupposedtobeunique?(1个回答)关闭4年前。我正在学习C++,很明显,一种检查std::map中是否存在特定键的方法是使用成员函数count。但我的第一个想法是:键不应该是唯一的吗?并检查documentation实际上它们是唯一的,因此count将返回0或1。把它叫做count是不是有点违反直觉?为什么不存在?对我来说,在您期望元素出现多次的列表中计数是有意义的,但如果该方法只允许返回1或0,那对我来说就没有意义。我错过了什么吗?是否有理由将其称为coun

c++ - 奇怪的 "Could not deduce template argument for ' T'"错误

错误在this代码://myutil.htemplateTConditionalInput(LPSTRinputMessage,LPSTRerrorMessage,predicatecondition);//myutil.cpptemplateTConditionalInput(LPSTRinputMessage,LPSTRerrorMessage,Predcondition){Tinputcout>input;while(!condition(input)){cout>input;}returninput;}...//c_main.cppintrow;row=ConditionalI

c++ - cin.get() 不工作

我今天写了这个简单的程序,但我发现cin.get()拒绝工作,除非有2个。有什么想法吗?#includeusingnamespacestd;intmain(){intbase;while((base36)){cout>base;}stringbase_str="0123456789abcdefghijklmnopqrstuvwxyz";for(inti=0;i如果我将cin.get()移动到嵌套循环之前,循环运行然后暂停。如果我取出一个cin.get(),程序就会结束。我正在使用最新版本的bloodshedc++dev 最佳答案 你

C++ googlemocks : Getting a stack trace of an uninitialized call

模拟类看起来像这样:构造模拟类{MOCK_METHOD0(foo,void());};如果我忘记在模拟对象上设置预期的调用,我会得到这样的结果:GMOCKWARNING:Uninterestingmockfunctioncall-returningdirectly.Functioncall:foo()Stacktrace:并且堆栈跟踪为空。那么,为了获取堆栈跟踪必须做什么? 最佳答案 这描述了here:YoucancontrolhowmuchGoogleMocktellsyouusingthe--gmock_verbose=LEVE

c++ - Template类拷贝构造函数的写法

如何为模板类编写复制构造函数。因此,如果模板参数是另一个用户定义的类,它的复制构造函数也会被调用。下面是我的课templateclassVertex{public:Vertex(_TyVin):m_Label(in){}~Vertex(){}booloperator 最佳答案 要么a)根本不是,只依赖于编译器提供的默认值;或b)仅调用成员的复制构造函数:templatestructFoo{Tvar;Foo(constFoo&rhs):var(rhs.var){}};重点当然是编译器提供的默认拷贝构造函数做了完全一样的事情:它一个一个

c++ - cin.get() 循环

我试图从标准输入读取。第一行是我要阅读的行数。我接下来阅读的行将再次打印。这是代码:#includeusingnamespacestd;intmain(){intn;cin>>n;for(unsignedinti=0;i当我运行它并给出行数时,程序退出。我还没有弄清楚发生了什么,所以我决定在这里问一下。提前致谢。 最佳答案 混合格式化和未格式化的输入充满了问题。在您的特定情况下,这一行:std::cin>>n;消耗您键入的数字,但将'\n'留在输入流中。随后,这一行:cin.get(a,10);不消耗任何数据(因为输入流仍然指向'\