1 | // Boost.Function library |
---|---|
2 | |
3 | // Copyright Douglas Gregor 2001-2003. Use, modification and |
4 | // distribution is subject to the Boost Software License, Version |
5 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
6 | // http://www.boost.org/LICENSE_1_0.txt) |
7 | |
8 | // For more information, see http://www.boost.org |
9 | |
10 | #include <boost/function.hpp> |
11 | #include <boost/core/lightweight_test.hpp> |
12 | #include <stdexcept> |
13 | #include <new> |
14 | |
15 | struct stateless_integer_add { |
16 | int operator()(int x, int y) const { return x+y; } |
17 | |
18 | void* operator new(std::size_t n) |
19 | { |
20 | BOOST_ERROR( "stateless_integer_add incorrectly allocated"); |
21 | return ::operator new( n ); |
22 | } |
23 | |
24 | void* operator new(std::size_t, void* p) |
25 | { |
26 | return p; |
27 | } |
28 | |
29 | void operator delete(void* p) throw() |
30 | { |
31 | BOOST_ERROR( "stateless_integer_add incorrectly deallocated"); |
32 | return ::operator delete( p ); |
33 | } |
34 | }; |
35 | |
36 | int main() |
37 | { |
38 | boost::function2<int, int, int> f; |
39 | f = stateless_integer_add(); |
40 | |
41 | return boost::report_errors(); |
42 | } |
43 |