摘要: 1.保存I/O流下面这段代码cout会失效,原因是cout重定向之后失效。#include #include using namespace std;//using namespace boost;int main(){ string filename("c:/test.txt"); cout << "log start" <<endl; if (!filename.empty()) { ofstream fs(filename.c_str()); cout.rdbuf(fs.rdbuf()); } cout << & 阅读全文
posted @ 2013-08-17 22:54 l851654152 阅读(355) 评论(0) 推荐(0) 编辑
摘要: shared_pt很强大的功能,但是也有缺陷1.重复析构2.循环使用,内存泄漏。 阅读全文
posted @ 2013-08-17 13:40 l851654152 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 1.trait特性可以和特化或者偏特化结合。2.trait可以和类型转换结合。 阅读全文
posted @ 2013-08-17 13:39 l851654152 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 1.random随机数产生,需要种子,下面以时间为种子示例:#include #include #include #include #include using namespace std;using namespace boost;int main(){ mt19937 rng(time(0)); for (int i = 0;i < 100;++i) { cout << rng() << "-" <<endl; } return 0;} 阅读全文
posted @ 2013-08-17 12:24 l851654152 阅读(278) 评论(0) 推荐(0) 编辑
摘要: STL里的算法已经很好了,在boost里有几个小的算法1.BOOST_FOREACH使用方法,定义一个容器里内部类型数据,容器作为参数传递。#include #include #include #include #include using namespace std;using namespace boost::assign;int main(){ vector v = list_of(1)(2)(3)(4)(5); BOOST_FOREACH(int x,v) { cout #include #include #include #include #include #include us.. 阅读全文
posted @ 2013-08-17 11:29 l851654152 阅读(2016) 评论(0) 推荐(0) 编辑
摘要: 1.静态数组array,boost对静态数组进行了封装,使用和普通数组一样的初始化式进行初始化。#include #include using namespace std;using namespace boost;int main(){ array ar; ar.back() = 10; array ar1 = {"tiger","dog","cat"}; return 0;}2.dynamic_bitset可以自由扩充二进制位的位数,可以自由进行位操作,还有一堆方便操作判断的函数。#include #include using n 阅读全文
posted @ 2013-08-17 00:51 l851654152 阅读(3434) 评论(0) 推荐(0) 编辑