|
Boost : |
From: Itay Maman (itay_maman_at_[hidden])
Date: 2003-02-18 14:49:54
-Itay
"Rodolfo Lima" <rodolfo_at_[hidden]> wrote in message
news:b2tm6v$9o7$1_at_main.gmane.org...
> How different is boost::any from this new variant library? Don't they
> address the same issue?
>
In short:
(1) boost::any can accept a value of any possible type. boost::variant
accepts only values of a finite set of types, which are passed as template
parameters
(2) boost::any offers a query-based mechanism for accessing its held value:
any_cast<T>(a); This operation may fail (at runtime). The equivalent
facility of boost::variant is: apply_visitor(a_visitor, a_variant). This
operation will fail at *compile-time* if a_visitor is not a valid visitor
for a_variant. More details can about visitation can be found in variant's
docs.
-Itay
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk