|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2002-07-25 05:47:07
From: "Eric Friedman" <ebf_at_[hidden]>
> So to put this into a concrete example (using Boost.Lambda), your
proposal
> would have the following syntax:
>
> apply(std::cout << _1, var); // display the contents of var
>
> rather than my proposed syntax:
>
> var.visit_with(std::cout << _1);
>
> or Itay's proposed syntax:
>
> var(std::cout << _1);
>
> I'm not sure whether I like yours or mine better. Anyone else have an
> opinion?
FWIW, seeing all of the examples you've written here, I'm now /certain/
that I like my syntax best.
-Dave
> P.S. One further observation/question: if we continue to go down this
road
> of preferring free functions over members, should variant::type be
removed
> as well? The functionality of variant::type is captured entirely by:
>
> const std::type_info& type = var.visit_with(ll_typeid(_1));
>
> or, in terms more verbose (but more portable to broken compilers):
>
> struct reflector : generic_visitor<const std::type_info&> //
> generic_visitor provides result_type member
> {
> template <typename T>
> result_type operator()(const T& operand) const
> { return typeid(operand); }
> };
> ...
> const std::type_info& type = var.visit_with(reflector());
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk