|
Boost : |
From: Eric Friedman (ebf_at_[hidden])
Date: 2002-07-24 20:52:24
Itay and I have come across the following disagreement in our
collaboration on Boost.Variant and so decided to poll the larger Boost
community for its opinions:
Should boost::variant visitation be provided via a named member function
(e.g., one of the following: variant::visit_with, variant::visit,
variant::accept, etc.) or via the unnamed function-call operator (i.e.,
variant::operator())?
I favor the former because variant is conceptually not a functionable
type (and so, IMO, shouldn't have operator() -- as opposed to a type
such as boost::function, for example) and because it stands out more
clearly and explicitly in user code. For example:
var.visit_with(visitor);
as opposed to:
var(visitor);
Itay believes variant::operator() will serve useful for situations where
std::for_each (or a similar algorithm) is invoked over a range of
visitor objects. IMO, this is a rather specialized use-case and so
shouldn't design variant's syntax around it (particularly when a simple
function object adaptor would facilitates Itay's desired usage).
Opinions?
Thanks,
Eric
P.S. Note that there is no disagreement between Itay and me regarding
invocation of the actual visitor objects; we both believe that this
should be handled via the function-call operator (i.e.,
SomeVisitor::operator()).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk