Boost logo

Boost :

From: Andrey Semashev (andysem_at_[hidden])
Date: 2005-09-23 15:04:59

Peter Dimov wrote:
> Andrey Semashev wrote:
>> So, there was a really interesting and hot discussion about namings.
>> Many opinions were expressed and I'd like to make some roundup.
> I still think that the question "should X be included at all" is
> slightly more fundamental than "should X be named rearm, protect, or
> on". But this
> may be just me.

I'm sorry I didn't answer directly to you, but I wrote this in one of the
descussion threads:

The more common use case is to create initially disabled guard and then,
depending on some condition, activate it. I've had the need of such
functionality several times.

The example may be made up. Imagine we have some function that plays the
role of a common entry point that dispatches objects of different types. For
simplicity all objects support interface IObject that have a method GetType.
The objects should be dispatched to different another entities depending on
their type. But for some objects some post-actions should be made.

void Entry(IObject* pObj)
    scope_guard g = make_guard(&PostActions, guard::disarmed);

    switch (pObj->GetType()) {
        case eType1:
            m_pEntity1->Process(pObj); // may throw
        case eType2:
            m_pEntity2->Process(pObj); // may throw

        case eType3:
            m_pEntity3->Process(pObj); // may throw

Another example. Assume you have to operate with some non-trivial object.
Something like that:

void foo(CObject const& obj)
    scope_guard g = make_guard(&PostActions, guard::disarmed);


    if (obj.is_ok()) {

        if (obj.foo3(param))



Both examples are very simplified but I hope they show the picture.

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