摘要: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 =
阅读全文
摘要: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
阅读全文
摘要: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都有对应的几.
阅读全文
摘要: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的
阅读全文