
4 Sep
2008
4 Sep
'08
7:32 p.m.
AMDG David Abrahams wrote:
There is still some value in storing functors in optional<T>: boost.lambda expressions are not asignable, thus rendering any iterator that contains a lambda does no longer meet the requirements of Assignable of which TrivialIterator is a refinement of.
It is easy to add a wrapper around optional<T> that makes it Assignable as long as T is copy constructible (which lambdas are), so it can be used as a quick workaround for this problem.
But for that you wouldn't need the bool in optional.
I think that you do need it, actually. I assume that assignment would be implemented with destroy + reconstruct? In this case, you need to deal with the possibility of the copy constructor throwing. In Christ, Steven Watanabe