草庐IT

template-parameter-lists

全部标签

c++ - 为什么 boost::assign::list_of 不适用于 pair<string, vector<string>>?

我不明白为什么这不起作用(VisualC++2012):#include#include#include#includeusingnamespacestd;intmain(){pair>("^",boost::assign::list_of("rules"));}错误是:include\utility(138):errorC2668:'std::vector::vector':ambiguouscalltooverloadedfunctionwith[_Ty=std::string]include\vector(786):couldbe'std::vector::vector(std:

c++ - 标准 :forward inside a template class

templateclassBlockingQueue{std::queuecontainer_;templatevoidpush(U&&value){static_assert(std::is_same::type>::value,"Can'tcallpushwithoutthesameparameterastemplateparameter'sclass");container_.push(std::forward(value));}};我希望BlockingQueue::push方法能够处理T类型对象的右值和左值引用,以将其转发到std::queue::push正确的版本。是像上面

c# - 如何向 MFC 应用程序添加 list 并设置支持的操作系统?

我正在尝试为WindowsServer2012运行Microsoft平台就绪测试工具4.6:http://www.microsoft.com/en-ca/download/details.aspx?id=41676我遇到了一个问题。它提示我有一个MFC应用程序有一个list,但该list缺少supportedOS部分。我知道如何将它添加到C#项目中,但如何在MFC应用程序中添加它?MFC应用程序显示在“list中缺少支持的操作系统部分的可执行文件”下。 最佳答案 刚收到。过程如下:右键单击您的解决方案,转到“属性”。从配置属性向下钻

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++ - 通过插入保持 std::list 迭代器有效

注意:这不是我应该“使用列表还是双端队列”的问题。这是一个关于迭代器在面对insert()时有效性的问题.这可能是一个简单的问题,我太笨了,看不出正确的方法。我正在实现(无论好坏)网络流量缓冲区作为std::listbuf,并且我将我当前的读取位置保持为迭代器readpos.当我添加数据时,我会做类似的事情buf.insert(buf.end(),newdata.begin(),newdata.end());我现在的问题是,如何保留readpos迭代器有效吗?如果它指向旧buf的中间,那么它应该没问题(由std::list的迭代器保证),但通常我可能已经读取并处理了所有数据并且我有re

c++ - 为什么 list::push_back 在 VC++ 中比在 g++ 中慢得多?

此代码在我的VS2012中大约需要20秒,但在G++中仅需1.x秒。均在win8x64中并使用默认选项编译。listitems;for(inti=0;i是关于内存分配的吗?在我的机器上用VC++输出后释放内存需要3~5秒,而在我friend的(win7x64)上甚至超过1分钟。 最佳答案 嗯...我扩展了您的代码以包含计时:#include#include#include#includeintmain(){std::listitems;clock_tstart=clock();for(inti=0;i我用VC++编译使用:cl/O2

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++ - 为什么 GCC 中 std::list O(n) 的 size() 方法?

在GCC中,std::list的size()方法是O(n)。为什么?对于C++11,标准是size()oflistshouldbeO(1)但是在glibc中我们有以下内容:/usr/include/c++/4.6.3/bits/stl_list.htemplate>classlist:protected_List_base{...size_typesize()const{returnstd::distance(begin(),end());}问题是:为什么三年前的要求还没有在GCC中实现?编辑:gcc5改变了这一点:尽管以ABI改变为代价;这意味着使用gcc5.0编译的C++代码将无法

java中把一个list转tree的三种方法——工具类

java中把一个list转tree的三种实现方法如何使用:如果你的类中主键名称为id,父节点id名称为parentId,子节点列表名称为children,数据库中顶层父节点id值为“0”,可以直接调用只需传入需要转换list的方法。否则需要传入相应的字段名称,或者修改代码。importorg.apache.commons.collections.CollectionUtils;importorg.apache.commons.lang3.StringUtils;importjava.lang.reflect.Field;importjava.util.ArrayList;importjava.