Boost logo

Boost :

From: Andrey Semashev (andysem_at_[hidden])
Date: 2007-08-22 14:19:11

Hello Maxim,

Wednesday, August 22, 2007, 9:54:59 PM, you wrote:

> A couple of general comments after reading other reviews.

> 1. The fact that the library takes all arguments by reference looks unavoidable.
> If it allowed passing by value (i.e. making copies) - the copy constructors can
> throw, and this exception will be thrown after you made the change to your
> container/whatever you'd like to rollback, and before you setup the rollback
> action. So you can't guarantee that your rollback action will be executed.

> So, in case you need a copy - it's much safer to create this copy before making
> the change to your container/whatever. It will also express your intention more
> clearly.

Generally speaking, you are right here. But first, there are many
objects that don't throw on copying. And second, it's not always
possible to make a copy beforehand. See one of my previous posts for
an example (inserting into container yelds an iterator that is to be
used in the scope-exit block). So I think the best way is to leave the
decision up to user.

Best regards,
 Andrey                            mailto:andysem_at_[hidden]

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