Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-07-21 08:42:08

From: "Douglas Gregor" <gregod_at_[hidden]>

> On Sunday 21 July 2002 07:43 am, Itay Maman wrote:
> > > extract<T> can be added at any time, so it might as well come along
> > > variant.
> >
> > This brings me to this point: The variant equivalent of any_cast<>,
> > variant_cast<>, has been renamed to boost::extract<>. This reduces the
> > level of compatibility with boost::any even further. Given this,
> > we drop variant::empty() ?
> >
> > -Itay
> I think that 'extract' was meant as a general mechanism, so it would work
> boost::any also. So the correspondence between boost::any and variant
> be 'close': bounded uses of boost::any could be replaced by variant by:
> 1) Replacing the boost::any type with the appropriate variant
> 2) Replacing 'any_cast' with 'extract'

That was my understanding also. Incidentally, I recently implemented
extract<> for Boost.Python.

extract<> is a class template which admits the following uses:

    int y = extract<int>(x);
    extract<int> xint((z));

    if (xint.check())
        int i = xint();
    return extract<foo&>(z);

I realize that poses some problems for unification, since it's not possible
to non-intrusively customize constructors for a single class template. I'm
willing to discuss changes, if neccessary.


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