草庐IT

boost-program-options

全部标签

使用语言环境时 C++ boost 崩溃

我正在尝试使用boost库为我的字符串类提供i18支持。我正在使用MicrosoftVisualStudio编译器VC10和64位Windows7机器。我能够编译我的应用程序并将其与boost库链接,但是我的应用程序在调用boost::locale::to_upper()时崩溃。下面是我写的代码。#include#include#includeString::MakeUpper()(){boost::locale::generatorgen;std::localeloc=gen("");std::locale::global(loc);std::stringstr2=boost::lo

c++ - 迭代 boost::icl::interval_set

我正在迭代boostinterval_set,我期望每个迭代器都是一个boostinterval,其值将通过upper访问和lower方法:boost::icl::interval_setoutages;//...//Insertintervalsintothedatabasefor(boost::icl::interval_set::iteratorit=outages.begin();it!=outages.end();it++){DATA_ACQUISITION::InsertInterval(db,it->lower(),it->upper())}但我在两个lower都收到错误

c++ - InterlockedExchangePointer 是否有裸露的 c++ 11(或 boost)替代品?

寻找Win32InterlockedExchangePointer的便携、简单和优雅的替代品。理想情况下仅使用C++11,但boost也可以。 最佳答案 standardatomictypes有一个原子exchange功能。所以微软人PVOIDvolatiletarget;old_value=InterlockedExchangePointer(&target,new_value);会变成std::atomictarget;old_value=target.exchange(new_value);

c++ - 使用 boost::lexical_cast 将 UUID 转换为字符串时出现 Boost 编译错误

我有这段代码是基于SO中的几篇文章:boost::uuids::uuiduuid=boost::uuids::random_generator()();autouuidString=boost::lexical_cast(uuid);但是当我编译这段代码时,我得到了这个错误:Sourcetypeisneitherstd::ostream`ablenorstd::wostream`ableC:\Local\boost\boost\lexical_cast\detail\converter_lexical.hpp我该如何修复这个错误? 最佳答案

c++ - 比较由 Boost Graph Library 创建的 2 个图

这可能是一个相当新手甚至错误的问题,所以请原谅。有没有一种方法可以比较使用BoostGraphLibrary=>创建的2个图与在内存中创建的1个图以及从存档加载的第2个图(即第2个之前已序列化)?我没有在BGL的文档中看到运算符==,但不确定这是否意味着我必须同时编写遍历和比较。任何指向教程、引用页或示例的指针都将是最有帮助的提前致谢象头神 最佳答案 Boost.Graph可以做到这一点,但不能使用==运算符:http://www.boost.org/doc/libs/1_39_0/libs/graph/doc/isomorphis

c++ - boost 函数的Python方法

我有一个使用boostpython将boost::function作为参数导出到Python的方法。据我所读,boost::python应该支持boost::function而无需大惊小怪,但是当我尝试使用python方法调用该函数时,它给了我这个错误Boost.Python.ArgumentError:PythonargumenttypesinClass.createTimer(Class,int,method,bool)didnotmatchC++signature:createTimer(classClass{lvalue},unsignedlonginterval,classb

c++ - boost 正则表达式运行时错误

我正在尝试使用我在另一台计算机上编写的一些代码,将字符串拆分为标记。这段代码编译得很好。该代码也可以在其他一些计算机上按预期工作。我已设法将代码缩减为以下内容:#include#includetypedefstd::vectortoken_t;token_tgenerate_tokens(std::stringraw_input){//thisfunctionbreaksainputstringintotokens.Sotest100goesto2tokens"test"and"100".boost::regexre_splitter("\\s+");//thisusestherege

c++ - WaitForMultipleObjects 和 boost::asio 在多个 windows::basic_handle 上有什么区别?

我有一个HANDLE列表,由许多不同的IO设备控制。之间的(性能)差异是什么:在所有这些句柄上调用WaitForMultipleObjectsasync_readonboost::windows::basic_handle'saroundallthesehandlesWaitForMultipleObjects是O(n)时间复杂度吗?n个句柄?您可以以某种方式在windows::basic_handle上调用async_read对吗?或者这个假设是错误的?如果我在多个线程中调用同一个IO设备上的运行,处理调用是否会在这些线程之间平衡?这将是使用asio的主要好处。

c++ - 如何从 boost::posix_time::ptime 获取自纪元时间以来的毫秒数

我看过一些otheranswersonSO这表明我们可以通过从“其他”时间中减去纪元时间来获得以毫秒为单位的纪元时间,但是当我尝试时它不起作用:ptimeepoch=time_from_string("1970-01-0100:00:00.000");ptimeother=time_from_string("2011-08-0917:27:00.000");longdiff=(other-epoch).total_milliseconds();在这个阶段diff是-1349172576,它应该是一个正数,因为“其他”时间是2011年。有人知道是什么原因造成的吗?获取纪元以来的毫秒数的正

c++ - std::map of boost::mutex 具有奇怪的行为

我有这个代码://////DefaultNamespaces///usingnamespacestd;typedefmapt_map_shared_mutex;intmain(intargc,char**argv){t_map_shared_mutexlist_lock;boost::shared_mutexglobal_lock;stringi="ABC";boost::unique_lockl_lock(global_lock);boost::unique_locklock(list_lock[i]);//DoSomethingwiththatlocklock.unlock();l