Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-07-24 21:00:54

From: "Eric Friedman" <ebf_at_[hidden]>

> 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?

If I understand what this visitation business is about (I might not), I

    apply(visitor, var);

which goes nicely with



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