Boost logo

Proto :

Subject: Re: [proto] Best way to change tag in generator?
From: Eric Niebler (eric_at_[hidden])
Date: 2012-01-31 13:01:52


On Mon, Jan 30, 2012 at 4:53 AM, Mathias Gaunard
<mathias.gaunard_at_[hidden]> wrote:
> For a couple of reasons, I'm considering replacing the proto-provided
> operator tags by my own in the generator of my domain.
>
> What would the easiest and less costly way of doing it?

You mean, for instance, you want Proto's operator+ to return an
expression with a tag other than tag::plus? Can I ask why? You can do
this in a generator, but you're right to be cautious of compile times.
Proto will instantiate a bunch of templates while assembling each
expression before passing them to your generator, which would just rip
them apart and throw them away.

Your other option would be to use the (undocumented)
BOOST_PROTO_DEFINE_UNARY_OPERATOR and
BOOST_PROTO_DEFINE_BINARY_OPERATOR to define a complete alternate set
of operator overloads that use your tags instead of proto's. See
proto/operators.hpp. Nobody has ever done this and I don't know if it
would work.

Eric


Proto list run by eric at boostpro.com