Re: [proto] Best way to change tag in generator?

2012-01-31 Thread Eric Niebler
On Mon, Jan 30, 2012 at 4:53 AM, Mathias Gaunard
mathias.gaun...@ens-lyon.org 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 mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto


Re: [proto] Best way to change tag in generator?

2012-01-31 Thread Mathias Gaunard

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?


Yes.



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


I guess I won't take that option then ;)
___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto