2002-01-30 01:58:28 +00:00
|
|
|
// Boost.Function library
|
|
|
|
|
2003-10-01 04:10:37 +00:00
|
|
|
// Copyright Doug Gregor 2001-2003. Use, modification and
|
|
|
|
// distribution is subject to the Boost Software License, Version
|
|
|
|
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
2002-01-30 01:58:28 +00:00
|
|
|
|
|
|
|
// For more information, see http://www.boost.org
|
|
|
|
|
2003-11-23 16:17:24 +00:00
|
|
|
#include <boost/test/minimal.hpp>
|
2002-01-30 01:58:28 +00:00
|
|
|
#include <boost/function.hpp>
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
struct stateless_integer_add {
|
|
|
|
int operator()(int x, int y) const { return x+y; }
|
|
|
|
|
2003-01-30 14:22:28 +00:00
|
|
|
void* operator new(std::size_t, stateless_integer_add*)
|
2002-01-30 01:58:28 +00:00
|
|
|
{
|
|
|
|
throw std::runtime_error("Cannot allocate a stateless_integer_add");
|
|
|
|
}
|
|
|
|
|
2003-01-30 14:22:28 +00:00
|
|
|
void operator delete(void*, stateless_integer_add*) throw()
|
2002-01-30 01:58:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace boost {
|
|
|
|
template<>
|
|
|
|
struct is_stateless<stateless_integer_add> {
|
|
|
|
BOOST_STATIC_CONSTANT(bool, value = true);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
int test_main(int, char*[])
|
|
|
|
{
|
2002-09-24 17:28:58 +00:00
|
|
|
boost::function2<int, int, int> f;
|
2002-01-30 01:58:28 +00:00
|
|
|
f = stateless_integer_add();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|