2003-02-14 18:05:26 +00:00
|
|
|
// Function library
|
|
|
|
|
|
|
|
// Copyright (C) 2001-2003 Douglas Gregor
|
|
|
|
|
2003-10-01 04:10:37 +00:00
|
|
|
// Use, modification and 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)
|
2003-02-14 18:05:26 +00:00
|
|
|
|
|
|
|
// For more information, see http://www.boost.org/
|
2002-12-28 03:44:00 +00:00
|
|
|
|
2021-12-16 06:20:42 +02:00
|
|
|
#if defined(__clang__) && defined(__has_warning)
|
|
|
|
# if __has_warning( "-Wdeprecated-declarations" )
|
|
|
|
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2022-05-30 18:18:09 +03:00
|
|
|
#if defined(__GNUC__) && __GNUC__ >= 12
|
|
|
|
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
#endif
|
|
|
|
|
2002-12-28 03:44:00 +00:00
|
|
|
#include <boost/function.hpp>
|
|
|
|
#include <iostream>
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
struct X {
|
|
|
|
int foo(int);
|
|
|
|
};
|
2003-01-19 14:44:34 +00:00
|
|
|
int X::foo(int x) { return -x; }
|
|
|
|
|
2002-12-28 03:44:00 +00:00
|
|
|
int main()
|
|
|
|
{
|
2016-09-05 19:11:51 +02:00
|
|
|
#ifndef BOOST_NO_CXX98_BINDERS
|
2003-02-14 18:05:26 +00:00
|
|
|
boost::function<int (int)> f;
|
2002-12-28 03:44:00 +00:00
|
|
|
X x;
|
2003-02-14 18:05:26 +00:00
|
|
|
f = std::bind1st(
|
|
|
|
std::mem_fun(&X::foo), &x);
|
2002-12-28 03:44:00 +00:00
|
|
|
f(5); // Call x.foo(5)
|
2016-09-05 19:11:51 +02:00
|
|
|
#endif
|
2003-01-30 04:42:06 +00:00
|
|
|
return 0;
|
2002-12-28 03:44:00 +00:00
|
|
|
}
|