On 01/31/2012 07:01 PM, Eric Niebler wrote:

You mean, for instance, you want Proto's operator+ to return an
expression with a tag other than tag::plus?


Can I ask why?

I need to attach certain information to the type of operation that the tag represents, and putting that information as typedefs in the tag type itself would be fairly convenient.

Most of my tags are user-defined, except from the ones that map to built-in C++ operators.

Of course, I could also just have a mapping of proto tags to custom tags that have that information (that is what I'm currently doing).

I was just being curious whether another approach was possible.

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

I guess I won't take that option then ;)
proto mailing list

Reply via email to