Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame^] | 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 | |
| 12 | #include <boost/function.hpp> |
| 13 | #include <boost/detail/lightweight_test.hpp> |
| 14 | #include <iostream> |
| 15 | #include <functional> |
| 16 | |
| 17 | struct X { |
| 18 | int foo(int); |
| 19 | std::ostream& foo2(std::ostream&) const; |
| 20 | }; |
| 21 | int X::foo(int x) { return -x; } |
| 22 | std::ostream& X::foo2(std::ostream& x) const { return x; } |
| 23 | |
| 24 | int main() |
| 25 | { |
| 26 | ndnboost::function2<int, X*, int> f; |
| 27 | ndnboost::function2<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 | } |