|
Boost : |
From: Eric Friedman (ebf_at_[hidden])
Date: 2003-02-17 20:46:04
Fernando Cacciola wrote:
[snip]
> (3) variant<> dependency.
>
> We are just about to review boost::variant<>.
> I was planning to wrap optional<> around variant discarding its current
> implementation.
This might seem like a good idea in theory, but for the simple case
presented by optional<>, the baggage of variant's implementation is overkill
IMO.
It might be useful in the future, however, to build a tests for optional
that compares your boost::optional<T> against a suitably-wrapped
boost::variant<empty, T>.
> However, to support the in-place form and use variant<>, the later will
have
> to suppport this form itself.
>
> Proposed solution:
[snip]
> ...I figured that a factory could move the forwarding problem out of
> optional<>
> while at the same time allow for an almost identical usage.
This seems like a good idea, particularly in terms of integrating
factory-based initialization with variant.
[snip]
> It allows to use in-place for noncopyable default-constructible objects:
>
> optional<Z> opt(true,in_place());
>
> It allows you to have alternative factories which support alternative
> forwarding methods:
>
> optional<X> opt(false,in_place2(2,"hello"));
>
> And since the factory can be reused, plugging the mechanism into
variant<>,
> for instance, is trivial.
>
> Notice that the verbosity is actually put in the in-place factory mainly.
> I would implement and document such factory as another utility and just
> use it on optional<> interface.
Let me know when you get this working for optional<>. I personally would be
quite interested in seeing how it might fit into variant<>. (I won't be
making any changes, however, until after variant's review has ended.)
> P.S: I'd really like to hear others opinions about this,
> specially from Eric Friedman and Itay Maman
> (the variant submitters).
Sorry for the slow reply <g>.
Eric
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk