IT点滴

我不去想是否能够成功 既然选择了远方 便只顾风雨兼程
  博客园  :: 首页  :: 联系 :: 订阅 订阅  :: 管理

06 2011 档案

摘要:我们先定义目标: 1. simple_bind 提供与 bind 类似的界面,可以只考虑通过对象引用(或者值)调用成员函数的情况,而不考虑 free function 或者通过指针调用等等。具体地说,就是允许 person.SetName("Ralph") --> simple_bind(&Person::SetName, person, _1)(string("Ralph")) simple_bind(&Person::SetName, _1, string(“Ralph"))(person) simple_bind(& 阅读全文

posted @ 2011-06-02 11:39 Ady Lee 阅读(244) 评论(0) 推荐(0)

摘要:Boost.bind 好用么?当然好用,而且它也确定进入下一代的 C++ 标准了,也早就进了 TR1 了。回顾一下,它允许我们干这个:#include <algorithm>#include <iostream>#include <string>#include <vector>#include <boost/bind.hpp>using namespace std;using namespace boost;struct Person{ Person(const string& name) : name_(name) {} 阅读全文

posted @ 2011-06-02 10:54 Ady Lee 阅读(340) 评论(0) 推荐(0)

摘要:bind - boost 头文件: boost/bind.hpp bind 是一组重载的函数模板.用来向一个函数(或函数对象)绑定某些参数. bind的返回值是一个函数对象. 它的源文件太长了. 看不下去. 这里只记下它的用法: 9.1 对于普通函数 假如有函数 fun() 如下: void fun(int x, int y) {cout << x << ", " << y << endl;}现在我们看看怎么用bind 向其绑定参数. 对于像 fun 这样的普通函数. 若fun 有n个参数. 则 bind 需要 n+1 个参数 阅读全文

posted @ 2011-06-01 16:35 Ady Lee 阅读(363) 评论(0) 推荐(2)