Small buffer optimization for Boost.Function

[SVN r32282]
This commit is contained in:
Douglas Gregor
2006-01-10 23:52:35 +00:00
parent 93c691fbdf
commit 78f6b385d5
6 changed files with 347 additions and 283 deletions

View File

@ -45,7 +45,7 @@ struct plus_int
{
int operator()(int x, int y) const { return x + y; }
int unused_state_data;
int unused_state_data[32];
};
static int do_minus(int x, int y) { return x-y; }
@ -54,7 +54,7 @@ struct DoNothing
{
void operator()() const {}
int unused_state_data;
int unused_state_data[32];
};
static void do_nothing() {}

View File

@ -14,23 +14,21 @@
struct stateless_integer_add {
int operator()(int x, int y) const { return x+y; }
void* operator new(std::size_t, stateless_integer_add*)
void* operator new(std::size_t)
{
throw std::runtime_error("Cannot allocate a stateless_integer_add");
}
void operator delete(void*, stateless_integer_add*) throw()
void* operator new(std::size_t, void* p)
{
return p;
}
void operator delete(void*) throw()
{
}
};
namespace boost {
template<>
struct is_stateless<stateless_integer_add> {
BOOST_STATIC_CONSTANT(bool, value = true);
};
}
int test_main(int, char*[])
{
boost::function2<int, int, int> f;