Boost logo

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.,

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:


as opposed to:


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).



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.,

Boost list run by bdawes at, gregod at, cpdaniel at, john at