草庐IT

BOOST_STATIC_ASSERT

全部标签

c++ - C 和 C++ 中的 Const、static、extern 及其组合

很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭10年前。1)static、extern和const有何不同,它们在C和C++中的使用有何不同?(默认联动等差异)2)C中使用的头文件中允许以下声明和定义,然后包含在多个文件中。staticinttestvar=233;externintone;externintshow();intabc;constintxyz;//constintxyz=123;produceserrorconstdefinition

c++ - 使用迭代器从 boost 多索引中删除项目时的一致性

我知道下面的代码对于std::vectors和更普遍的所有STL容器来说是不正确的:std::vector::iteratorit=array.begin();for(;it!=array.end();it++){...array.erase(it);...}因为删除元素后需要更新迭代器。我想知道boost多索引是否相同,例如,下面的内容是否正确:my_index::iteratorit=index.get().begin();for(;it!=index.get().end();it++){...index.erase(it);...}我想确保理解文档的以下段落:http://www

c++ - boost::container 是否支持 C++11 初始化列表?

在Boost.Container网站上我们可以看到:Boost.Containerdoesnotsupportinitializerlistswhenconstructingorassigningcontainersbutitwillsupportitforcompilerswithinitialized-listsupport.(...)对不起,如果我只是愚蠢,但我真的不知道如何阅读它。这是否意味着它会在不可预测的future这样做,或者它现在应该与符合标准的编译器一起工作?我已经在GCC4.7和ICC13.0上测试过它,两者都不起作用,但我相信我可能错过了一些非常重要的东西,比如正

c++ -/boost/lockfree/queue.hpp: 错误: 静态断言失败: (boost::has_trivial_destructor<T>::value)

我正在尝试替换boost::lockfree::queue对于std::queue在这个文件中https://github.com/zaphoyd/websocketpp/blob/experimental/examples/broadcast_server/broadcast_server.cpp我添加了#include;改线130,std::queuem_actions;,至boost::lockfree::queuem_actions;;删除所有与锁定有关的行;并更改了行103,m_actions.pop();,至m_actions.pop(a);.我在sconsbroadcas

c++ - 为什么 boost filter_iterator 有奇怪的 make_filter_iterator 函数?

在经历了一些痛苦之后,我设法拼凑了这个boostfilter_iterator的最小示例usingnamespacestd;std::functionstlfunc=[](uint32_tn){returnn%3==0;};intmain(){vectornumbers{11,22,33,44,55,66,77,3,6,9};autostart=boost::make_filter_iterator(stlfunc,numbers.begin(),numbers.end());autoend=boost::make_filter_iterator(stlfunc,numbers.end

c++ - 为什么 boost 的随机数生成(正态分布)总是给出相同的值?

我正在生成一些随机数并出现可疑行为。这是我的代码://initializedearlier...intheconstructorofaclassboost::mt19937*rng=newboost::mt19937();rng->seed(time(NULL));//actualusehere.for(inti=0;idistribution(10,10);boost::variate_generator>resampler(*rng,distribution);constdoublesample=(resampler)();//alwaysthesamevalue.}我是否滥用了b

c++ - 使用 boost::is_any_of 拆分会混淆定界符 ",,"和 ","

我目前有一个具有以下结构的字符串xxx,xxx,xxxxxxx,,xxxxxx,xxxx现在我使用下面的代码std::vectorvct;boost::split(vct,str,boost::is_any_of(",,"));现在,一旦找到“,”而不是我不想要的“,,”,boost就会拆分字符串。有什么方法可以让我明确指定只有在找到“,,”而不是“,,”时才拆分 最佳答案 is_any_of(",,")将匹配列表中指定的任何内容。在这种情况下,,或,你要找的是沿线boost::algorithm::split_regex(vct,

c++ - boost 中的矩阵求逆

我正在尝试使用boost进行简单的矩阵求逆运算。但是我我收到一个错误。基本上我想找到的是inversted_matrix=逆(反式(矩阵)*矩阵)但是我收到一个错误Checkfailedinfileboost_1_53_0/boost/numeric/ublas/lu.hppatline299:detail::expression_type_check(prod(triangular_adaptor(m),e),cm2)terminatecalledafterthrowinganinstanceof'boost::numeric::ublas::internal_logic'what(

c++ - 如何从 boost::timer::cpu_timer 获取耗时(以秒为单位)?

以下粗略代码,基于thedocumentation,给我从boost中提供的计时器对象中耗时(以秒为单位)。boost::timer::cpu_timertimer;//...dosomework...constboost::timer::nanosecond_typeoneSecond(1000000000LL);returntimer.elapsed().user/oneSecond;这个方法的问题是我的代码中有这个令人不舒服的魔数(MagicNumber)。boost中是否有某种方法可以从nanosecond_type值中为我提供elapsed().user调用中可用的elaps

c++ - 为什么 boost::any 不保存字符串文字?

#include#include#include#includestruct_time_t{intmonth;intyear;};intmain(){std::stringstr="hahastr";_time_tt;std::vectorobjVec;objVec.push_back(1);char*pstr="haha";//boost::anycharArr="haha";notcompile//objVec.push_back("haha");notcompileobjVec.push_back(pstr);objVec.push_back(str);objVec.push_b