随笔分类 -  Boost

函数对象function object 以及boost::bind的一点了解
摘要:1 function object就是重载了operator()的类的对象, 像如下例子, 其实也许应该说是定义了operator()的类, 在thinking in c++中operator overloading都并没有提到operator() 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 class Wy { 5 public : 6 string operator()(string msg, int a, int b){ 7 cout << "msg = 阅读全文

posted @ 2012-05-18 12:18 小宇2 阅读(856) 评论(0) 推荐(0) 编辑

分隔和截断字符串, boost string algorithm library中的split和trim
摘要:http://www.boost.org/doc/libs/1_46_1/doc/html/string_algo.html这个库是个 headers only library 这个库提供了STL没有提供的 string-related算法, 但是实现做到了可以用在任何 character 的 container上split在写在线状态的改造时候要把一个字符串中描述的几种类型拆出来, 引发了这个问题, 去标准库里找了也没找到, 后来在boost库中找到了string_algo这个库, 以下是我写的一个使用split的例子 1 #include <boost/algorithm/strin 阅读全文

posted @ 2012-05-15 15:20 小宇2 阅读(13603) 评论(0) 推荐(0) 编辑

boost::thread中的锁
摘要:http://www.boost.org/doc/libs/1_46_1/doc/html/thread/synchronization.htmlmutex 是mutual exclusion(互斥), 是一个概念 , A mutex object facilitates protection against data races and allows thread-safe synchronization of data between threads, 这句话描述了mutex object的作用, 在这篇文档中, 定义了几4种 mutex concept, 每种concept都有对应的几. 阅读全文

posted @ 2012-03-12 17:14 小宇2 阅读(952) 评论(0) 推荐(0) 编辑

smart pointer --- shared_from_this的使用
摘要:shared_ptr enable_shared_from_this一种避免内存泄漏的方式是, always use a named smart pointer variable to hold the result of newshared_ptr<T> p(new T);http://hi.baidu.com/jrckkyy/blog/item/ac3e5511fa4a59caa6ef3ff1.html 这篇文章讲了shared_from_this几个值得注意的地方, 看了几次,然后去翻阅了下源码,搞明白了boost文档中首先讲了enable_shared_from_this的 阅读全文

posted @ 2012-03-05 11:20 小宇2 阅读(6247) 评论(0) 推荐(1) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示