1// Function library
2
3// Copyright (C) 2001-2003 Douglas Gregor
4
5// Use, modification and distribution is subject to the Boost Software
6// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8
9// For more information, see http://www.boost.org/
10
11#if defined(__clang__) && defined(__has_warning)
12# if __has_warning( "-Wdeprecated-declarations" )
13# pragma clang diagnostic ignored "-Wdeprecated-declarations"
14# endif
15#endif
16
17#if defined(__GNUC__) && __GNUC__ >= 12
18# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
19#endif
20
21#include <boost/function.hpp>
22#include <iostream>
23#include <functional>
24
25struct X {
26 int foo(int);
27};
28int X::foo(int x) { return -x; }
29
30int main()
31{
32#ifndef BOOST_NO_CXX98_BINDERS
33 boost::function1<int, int> f;
34 X x;
35 f = std::bind1st(
36 fn: std::mem_fun(f: &X::foo), x: &x);
37 f(5); // Call x.foo(5)
38#endif
39 return 0;
40}
41

source code of boost/libs/function/test/std_bind_portable.cpp