| Line | |
|---|
| 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/test/minimal.hpp> |
|---|
| 11 | #include <boost/function.hpp> |
|---|
| 12 | #include <stdexcept> |
|---|
| 13 | |
|---|
| 14 | struct stateless_integer_add { |
|---|
| 15 | int operator()(int x, int y) const { return x+y; } |
|---|
| 16 | |
|---|
| 17 | void* operator new(std::size_t, stateless_integer_add*) |
|---|
| 18 | { |
|---|
| 19 | throw std::runtime_error("Cannot allocate a stateless_integer_add"); |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | void operator delete(void*, stateless_integer_add*) throw() |
|---|
| 23 | { |
|---|
| 24 | } |
|---|
| 25 | }; |
|---|
| 26 | |
|---|
| 27 | namespace boost { |
|---|
| 28 | template<> |
|---|
| 29 | struct is_stateless<stateless_integer_add> { |
|---|
| 30 | BOOST_STATIC_CONSTANT(bool, value = true); |
|---|
| 31 | }; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | int test_main(int, char*[]) |
|---|
| 35 | { |
|---|
| 36 | boost::function2<int, int, int> f; |
|---|
| 37 | f = stateless_integer_add(); |
|---|
| 38 | |
|---|
| 39 | return 0; |
|---|
| 40 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.