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
|
2003-10-01 04:10:37 +00:00
|
|
|
// 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/function.hpp>
|
2018-09-24 19:23:58 +03:00
|
|
|
#include <boost/core/lightweight_test.hpp>
|
2002-01-30 01:58:28 +00:00
|
|
|
#include <stdexcept>
|
2018-09-24 19:23:58 +03:00
|
|
|
#include <new>
|
2002-01-30 01:58:28 +00:00
|
|
|
|
|
|
|
struct stateless_integer_add {
|
|
|
|
int operator()(int x, int y) const { return x+y; }
|
|
|
|
|
2018-09-24 19:23:58 +03:00
|
|
|
void* operator new(std::size_t n)
|
2002-01-30 01:58:28 +00:00
|
|
|
{
|
2018-09-24 19:23:58 +03:00
|
|
|
BOOST_ERROR( "stateless_integer_add incorrectly allocated" );
|
|
|
|
return ::operator new( n );
|
2002-01-30 01:58:28 +00:00
|
|
|
}
|
|
|
|
|
2006-01-10 23:52:35 +00:00
|
|
|
void* operator new(std::size_t, void* p)
|
2002-01-30 01:58:28 +00:00
|
|
|
{
|
2006-01-10 23:52:35 +00:00
|
|
|
return p;
|
2002-01-30 01:58:28 +00:00
|
|
|
}
|
|
|
|
|
2018-09-24 19:23:58 +03:00
|
|
|
void operator delete(void* p) throw()
|
2006-01-10 23:52:35 +00:00
|
|
|
{
|
2018-09-24 19:23:58 +03:00
|
|
|
BOOST_ERROR( "stateless_integer_add incorrectly deallocated" );
|
|
|
|
return ::operator delete( p );
|
2006-01-10 23:52:35 +00:00
|
|
|
}
|
|
|
|
};
|
2002-01-30 01:58:28 +00:00
|
|
|
|
2018-09-24 19:23:58 +03:00
|
|
|
int main()
|
2002-01-30 01:58:28 +00:00
|
|
|
{
|
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();
|
|
|
|
|
2018-09-24 19:23:58 +03:00
|
|
|
return boost::report_errors();
|
2002-01-30 01:58:28 +00:00
|
|
|
}
|