
AMDG Mathias Gaunard <mathias.gaunard <at> etu.u-bordeaux1.fr> writes:
The problem with small object optimization is that you get the same issue that boost.variant has: it's hard to maintain the never-empty guarantee in operator=, because the copy constructor of a new value can throw and thus you lose the old value.
When I was trying to do this I only used the small object optimization for types that I knew to have a no-throw copy constructor (i.e. builtin types at the moment). In C++Ox this can be loosened to having a no-throw move constructor.
I wonder, by the way, how boost.function solves that issue.
It doesn't. Boost.Function can be empty and assignment for Boost.Function does not provide the strong guarantee of exception safety. In Christ, Steven Watanabe