|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-06-14 10:21:42
Get it at
http://groups.yahoo.com/group/boost/files/bind/bind.hpp
http://groups.yahoo.com/group/boost/files/bind/bind_test.cpp
Example:
#include <iostream>
#include <boost/config.hpp>
#include <boost/function.hpp>
#include "bind.hpp"
using boost::rv;
using boost::lv;
int f_6(int a, int b, int c, int d, int e, int f)
{
std::cout << "( " << a << ", " << b << ", " << c << ", " << d << ", " << e
<< ", " << f << ")\n";
return 0;
}
int main()
{
int i(20);
boost::function<void, int, int, int> F = boost::bind<int>(f_6, _1, 10, _2,
i, _3, lv(i));
F(-1, -2, -3);
i = 94;
F(-1, -2, -3);
}
Output:
( -1, 10, -2, 20, -3, 20)
( -1, 10, -2, 20, -3, 94)
on MSVC 7.0b1, g++ 2.95.2, bcc32 5.5.1, Intel C++ 5.0.
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk