Boost logo

Boost :

Subject: Re: [boost] [any] New feature idea for boost.any
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2010-01-01 06:54:57


Andres B. wrote:
> Hello, i am Andrés, i am new in the boost world and i have an idea to
> boost.any.
>
> With the actual boost::any i can't do this:
>
> boost::any any_var;
> int i;
> any_var = 10;
> i = 1 + any_var;
> double d;
> // d = 1.0 + any_var; // throw: bad_any_cast, because any_var is int
> any_var = 10.0;
> d = 1.0 + any_var - 3.0; // now any_var is double

Any is type erasure for any type, or rather a type that is
CopyConstructible and Assignable.
What you want is type erasure for a type that is Addable as well, which
makes it more specific.


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