草庐IT

ZN5boost

全部标签

c++ - 当我安装了多个 Visual Studio 版本时,如何使用 Visual Studio 2008 构建 boost?

我知道如何在我的机器上使用最新的visualstudio构建boost(thisquestion,forexample)但是,我需要为VisualStudio2008(vc9)构建库我尝试使用toolset=vc9但我遇到了问题/没有成功。我如何为vc9构建库?在我运行boostrap之后,我尝试运行b2toolset=vc9但是输出是:C:/Development/boost50/boost_1_50_0/boost_1_50_0/tools/build/v2/build\toolset.jam:39:intoolset.usingrulevc9.initunknowninmodul

c++ - 为什么 boost::asio::io_service 不能用 std::bind 编译?

我正在尝试使用std::thread、std::bind和boost::asio编译简单的测试程序g++4.9.1(-std=c++11).但是,在创建新线程时,当我使用std::bind时,它不会编译。另一方面,当我切换到boost::bind时,一切都很好。代码如下:#include#include#include#include#include#includeintmain(intargc,char*argv[]){boost::asio::io_serviceioService;std::unique_ptrt;t.reset(newstd::thread(std::bind(

c++ - boost::shared_ptr 和继承

我面临这样一种情况,我有一个基类的boost::shared_ptr的std::vector。在我的程序过程中,我也需要在该vector中存储指向派生类对象的共享指针,并且在程序稍后的某个时间,需要检索这些共享指针。以下代码说明了我的问题:#include#includeusingnamespacestd;#include#includeclassBase{public:virtual~Base(){}};/******************************************/typedefboost::shared_ptrBasePtr;/**************

c++ - 使用 boost::any_range 有什么好处?

使用boost::any_range有什么好处?这是一个例子:typedefboost::any_rangeinteger_range;voiddisplay_integers(constinteger_range&rng){boost::copy(rng,std::ostream_iterator(std::cout,","));std::coutinput{...};std::listinput2{...};display_integers(input);display_integers(input2);}但是使用模板参数可以实现相同的功能并boost效率,这满足了ForwardR

c++ - BOOST_FOREACH 和没有 typedef 的模板

当我使用BOOST_FOREACH时,简单的模板作为vector没有问题。但是,当我尝试遍历map>例如,我需要对元素类型进行typedef。有什么解决方法吗? 最佳答案 有一个问题,因为它是一个宏,因此不能处理包含逗号的类型(预处理器不知道模板)。您也可以在循环之前声明变量,参见documentation.std::mapmy_map;//1)typedefstd::pairMyPair;BOOST_FOREACH(MyPairp,my_map){...}//2)std::pairp;BOOST_FOREACH(p,my_map)

C++:可以在构造函数中初始化 boost::scoped_ptr 吗?

boost::scoped_ptr类型的类成员可以在类的构造函数中初始化吗?怎么样?(不在初始化列表中) 最佳答案 是的。你可以使用reset()成员函数。classfoo{public:foo(){p.reset(newbar());}private:boost::scoped_ptrp;}; 关于C++:可以在构造函数中初始化boost::scoped_ptr吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverf

c++ - Boost::测试和模拟框架

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。关闭4年前。Improvethisquestion我正在使用boost::test并且需要使用模拟框架。有人有什么建议吗?

c++ - 为什么 Boost.Range is_sorted 不需要前向迭代器?

C++11算法std::is_sorted和std::is_sorted_until都需要ForwardIterator。然而,Boost.Range版本boost::is_sorted只需要与InputIterator相对应的SinglePassRange。特别是,它委托(delegate)给一个基于迭代器的实现,如下所示:templateinlineIteratoris_sorted_until(Iteratorfirst,Iteratorlast,Compc){if(first==last)returnlast;Iteratorit=first;++it;for(;it!=las

c++ - 如何快速测试新的 Boost 版本和库?

与许多C++程序员一样,我非常欣赏Boost库,并在许多项目中使用它们。因此,我喜欢及时了解定期添加的新库。但是,我经常发现自己想尝试一些新功能而无需在我的计算机上重新安装另一个版本。基本上,我希望能够快速尝试一些代码片段,而无需经历下载源代码和编译它们的负担。我尝试在在线编译器上这样做,例如ideone或codepad,但他们提供的Boost版本不是最新的(1.39forideone和1.34forcodepad)。你知道有什么在线编译器可以让我测试最新版本的Boost吗?如果没有,您如何继续仅测试某些库?如果我对svn存储库进行部分checkout,我如何确定我获取了所有依赖项?

c++ - 总结两个 boost::accumulator_set 实例

我最近发现了优秀的库boost::accumulators,我想用它来代替我的一些累加统计的代码。我在文档中找不到的一件事是对两个累加器集求和的能力,如operator+=例子:usingnamespaceboost::accumulators;typedefaccumulator_set>AccumSet;classFoo{AccumSetacc;public:Foo&operator+=(constFoo&that){this->acc+=that.acc;//error!nosuchoperatorreturn*this;}doubleGetVariance(){returnva