boost::bind 内に boost::bind

こんな事が出来たんですね。

#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <iostream>

int
double_(int n){
    return n + n;
}

void
disp(int n){
    std::cout << n << ",";
}

int
main(){
    boost::function<void(int)> f
        = boost::bind(disp, boost::bind(double_, _1));
    
    for(int i = 0 ; i < 10 ; ++i){
        f(i);
    }
    return 0;
}


[出力]

0,2,4,6,8,10,12,14,16,18,

便利便利。


[boost]
ver 1.46.1
[参照]
http://www.boost.org/doc/libs/1_46_1/libs/bind/bind.html#nested_binds