Boost logo

Boost :

Subject: Re: [boost] optional<optional<T>>
From: Sid Sacek (ssacek_at_[hidden])
Date: 2009-09-03 13:21:01


I'm new to boost::optional<>. I quickly looked through the online docs to see what this class does, and this was my first impression:

        boost::optional< char > c;

        if ( c )
        {
                // should not enter this block
        }
        c = 'a';

        if ( c )
        {
                // should enter this block
        }

>From what I was able to make out in 10-minutes, the class has a built-in boolean for the 'initialized' state so that it can be used in 'if()' statements. Also, the object it represents is not allocated until it is assigned ( if I'm not mistaken. )

I'm curious, what other bag of tricks does it come with?

Regards,
-Sid Sacek


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk