The following is a sketch of a potential use case for the newly-accepted and
already very useful 'optional' class. 

Suppose you have a pure RAII guard/locker which unconditionally does its
job:

    struct RAII_lock
        : boost::noncopyable
    {
        RAII_lock(entity& e);
        ~RAII_lock();
    };
    
and you want to write a semantic equivalent to the following

    boost::scoped_ptr<RAII_lock> lock( cond ? new RAII_lock(entity) : 0 );
    // ...

expect for the dynamic allocation part. How would you do it? 

IMO the following seems only natural:

    boost::optional<RAII_lock> lock( cond, entity );
    // ...

The only problem with the above is that currently you cannot write something
like this. It would be nice if we could, IMO.

Thoughts?

Aleksey
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to