草庐IT

boost-pool

全部标签

c++ - boost::spirit:语义 Action block 中的多个语句

boost::phoenix使用运算符“,”定义语句block(参见boostphoenixblockstatements)。我试图在boost::spirit规则的语义Action部分使用这个构造。但是,看起来只执行了语句block中的最后一条语句。这是一个显示问题的最小可编译示例:#include#include#include#include#include#include#include#includeintmain(){usingboost::spirit::qi::int_;usingboost::phoenix::ref;usingboost::spirit::qi::p

c++ - 转换 std::vector 为 boost::variant 类型

我如何实现下面的函数来从Value的vector进行转换?到Container?如果不是values的所有成员,我想断言是同一类型,即如果vector包含字符串和整数的混合。这是因为函数的返回值是std::vector。或std::vector.typedefboost::variantValue;typedefboost::variant,std::vector>Container;ContainervaluesToContainer(conststd::vector&values){returnContainer();} 最佳答案

C++:如何使用 boost::range 查找 max_element?

我正在尝试将迭代器返回到过滤范围内的最大元素。这是我目前所拥有的:#include#include#include#include#includeusingnamespaceboost::adaptors;usingnamespaceboost::lambda;usingnamespacestd;intmain(){vectorx={100,150,200,110};autoit=boost::max_element(x|indexed(0)|filtered(_1>100));/*problemhere*/cout我希望代码打印出vectorx中具有最大元素(即2)的索引,但不幸的是

c++ - BOOST_FUSION_ADAPT_TPL_STRUCT 和模板数组大小

由于BOOST_FUSION_ADAPT_TPL_STRUCT,我正在尝试迭代C++模板结构.我的结构包含固定大小的多维数组,其大小是模板参数。如果我们考虑修改Boost的示例以解决我的问题:#include#include#include#include//Example://http://www.boost.org/doc/libs/1_53_0/libs/fusion/doc/html/fusion/adapted/adapt_tpl_struct.htmlnamespacedemo{templatestructemployee{Namename;Ageage;Tar[SIZE1

c++ - 使用 boost::lambda::bind 有什么问题?

我正在尝试使用boost::lambda::bind()定义一个谓词,我将其传递给Boost.Range中的find_if算法。具体来说,我想搜索结构vector以找到特定成员具有指定值的第一个条目。我的例子如下:#include#include#includeusingnamespacestd;usingnamespaceboost;usingnamespaceboost::lambda;structfoo{strings;intx;};intmain(){//createlistandaddacoupleentriesvectorfooList;foof1={"abc",1};fo

c++ - 使用 Boost 避免用户在 C++ 项目中访问文本资源

我正在使用EclipseHelios、QT4.6.1集成插件和boost1.52库开发一个C++项目。我想从xml文件中提取一些要使用的信息,目前我正在通过调用boost函数constread_xml(std::string&,Ptree&,int=0,conststd::locale&=std::locale()).关键是我想避免最终用户从发布文件夹访问该xml资源,但我不知道该怎么做。有没有什么(简单的)方法可以处理可执行文件内部的xml内容,以便将其加载到内存中并继续其余的过程,就像我已经在将xml文件视为项目资源一样?任何提示都会让我非常感激。提前致谢。

c++ - boost::spirit 当词法分析器标记 > 10 时编译错误

当我尝试编译以下代码时,当token_list>10个标记时,出现编译失败(错误C2903:“应用”:符号既不是类模板也不是函数模板...)。当token#defineBOOST_VARIANT_MINIMIZE_SIZE#include#include#include#includenamespaceqi=boost::spirit::qi;namespacelex=boost::spirit::lex;templatestructtoken_list:lex::lexer{token_list(){cs1="tok1";cs2="tok2";cs3="tok3";cs4="tok4

c++ - 未找到 Boost 库,但编译正常

我正在尝试在C++中使用来自boost的文件系统使用的时候好像编译没问题"c++-cAnalyse.c-oAnalyse.o-g-W-Wall-L/usr/local/lib-lboost_filesystem-lboost_system"但是在尝试执行我的代码时出现以下错误:"errorwhileloadingsharedlibraries:libboost_filesystem.so.1.54.0:cannotopensharedobjectfile:Nosuchfileordirectory",afind/-iname"libboost_system.so.1.54.0我在安装b

c++ - 检测 boost 测试用例是否失败

我想记录更多关于BOOST断言失败的数据。不确定这是否可能以及如何实现。BOOST_AUTO_TEST_CASE(TestCase1){Datad;d.fillUp(...);d.operation1(...);BOOST_CHECK(d==...);d.operation2(...);BOOST_CHECK(d==...);...if(/*anythingabovefailed*/){log我对最后一个条件有疑问。你能建议吗?我希望错误日志指示发生断言时Data对象中的条件。理想情况下,我希望它们被转储一次,即使在测试用例中发生了多个断言。 最佳答案

c++ - 使用 boost::filesystem 3.0 迭代文件

我想遍历目录中与“keyword.txt”匹配的所有文件。我在谷歌搜索了一些解决方案,发现了这个:CanIuseamasktoiteratefilesinadirectorywithBoost?我后来发现,“leaf()”函数已被替换(来源:http://www.boost.org/doc/libs/1_41_0/libs/filesystem/doc/index.htm->转到“已弃用的名称和功能”部分)到目前为止我得到的是这个,但它没有运行。很抱歉这个有点愚蠢的问题,但我或多或少是一个C++初学者。conststd::stringtarget_path("F:\\data\\");