Files
boost_function/test/stateless_test.cpp
T

39 lines
825 B
C++
Raw Normal View History

2002-01-30 01:58:28 +00:00
// Boost.Function library
2004-07-25 02:59:30 +00:00
// Copyright Douglas 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
#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; }
void* operator new(std::size_t)
2002-01-30 01:58:28 +00:00
{
throw std::runtime_error("Cannot allocate a stateless_integer_add");
}
void* operator new(std::size_t, void* p)
{
return p;
}
void operator delete(void*) throw()
2002-01-30 01:58:28 +00:00
{
}
};
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;
}