blob: c55baa4e62442d52d525a041f4ffa0f373b3d42a [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001// 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
12#include <boost/function.hpp>
13#include <boost/detail/lightweight_test.hpp>
14#include <iostream>
15#include <functional>
16
17struct X {
18 int foo(int);
19 std::ostream& foo2(std::ostream&) const;
20};
21int X::foo(int x) { return -x; }
22std::ostream& X::foo2(std::ostream& x) const { return x; }
23
24int main()
25{
26 ndnboost::function<int (X*, int)> f;
27 ndnboost::function<std::ostream& (X*, std::ostream&)> f2;
28
29 f = &X::foo;
30 f2 = &X::foo2;
31
32 X x;
33 BOOST_TEST(f(&x, 5) == -5);
34 BOOST_TEST(f2(&x, ndnboost::ref(std::cout)) == std::cout);
35
36 return ::ndnboost::report_errors();
37}