Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-29 23:10:45

----- Original Message -----
From: "Douglas Gregor" <gregod_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, January 29, 2002 10:35 PM
Subject: [boost] Boost.Function optimization for stateless function objects

> I've just committed some changes to Boost.Function so that it will
> away unnecessary allocations and copying of stateless function objects.
> 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::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.


So, as I understand it, is_stateless requires user intervention or compiler
support, right?
It seems to me that you'd want is_stateless to be true in the following

    T is a function pointer
    T is const (? maybe not -- there might be a state* const in it)


Boost list run by bdawes at, gregod at, cpdaniel at, john at