|
Boost : |
From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-01-29 22:35:58
I've just committed some changes to Boost.Function so that it will optimize
away unnecessary allocations and copying of stateless function objects. Thus,
construction of or assignment to a Boost.Function object given a stateless
function object will not throw, and will not allocate any memory.
To do this, a new type trait, is_stateless, has been added to
boost/type_traits/object_traits.hpp. The definition of is_stateless is:
template <typename T>
struct is_stateless
{
BOOST_STATIC_CONSTANT(bool, value =
(::boost::type_traits::ice_and<
::boost::has_trivial_constructor<T>::value,
::boost::has_trivial_copy<T>::value,
::boost::has_trivial_destructor<T>::value,
::boost::is_class<T>::value,
::boost::is_empty<T>::value
>::value));
};
The functionality has been tested under GCC, Comeau, and MSVC without any
problems. Documentation may lag behind a bit, but I'm working on it.
Comments always welcome.
Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk