2001-07-14 19:57:09 +00:00
|
|
|
// Boost.Function library examples
|
|
|
|
|
2004-07-25 02:59:30 +00:00
|
|
|
// Copyright Douglas Gregor 2001-2003. Use, modification and
|
2003-10-01 04:10:37 +00:00
|
|
|
// distribution is subject to the Boost Software License, Version
|
|
|
|
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
2001-07-14 19:57:09 +00:00
|
|
|
|
|
|
|
// For more information, see http://www.boost.org
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <boost/function.hpp>
|
|
|
|
|
2003-10-01 04:10:37 +00:00
|
|
|
struct int_div {
|
|
|
|
float operator()(int x, int y) const { return ((float)x)/y; };
|
2001-07-14 19:57:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
2003-10-09 05:00:38 +00:00
|
|
|
boost::function<float (int, int)> f;
|
2001-07-14 19:57:09 +00:00
|
|
|
f = int_div();
|
|
|
|
|
|
|
|
std::cout << f(5, 3) << std::endl; // 1.66667
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|