|
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
with
> > > variant.
> >
> > This brings me to this point: The variant equivalent of any_cast<>,
i.e:
> > variant_cast<>, has been renamed to boost::extract<>. This reduces the
> > level of compatibility with boost::any even further. Given this,
shouldn't
> > we drop variant::empty() ?
> >
> > -Itay
>
> I think that 'extract' was meant as a general mechanism, so it would work
with
> boost::any also. So the correspondence between boost::any and variant
would
> be 'close': bounded uses of boost::any could be replaced by variant by:
> 1) Replacing the boost::any type with the appropriate variant
instantiation
> 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.
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk