On 7/18/2012 2:59 AM, Mathias Gaunard wrote:
> In an experiment to reduce compile times, I'd like to try reducing the
> number of template instantiations tied to the use of Proto.
> To do this, one could start by defining his own expression types instead
> of wrappers of proto::expr, which is something that is more-or-less
> promoted by proto-11.
> However, the proto_base_expr and proto_grammar typedefs still force
> those instantiations.
> Would it be possible to refine the concepts so as to avoid this?

The key to doing this would be in the implementation of proto::matches.
It uses proto_base_expr and proto_grammar as "normalized forms" of an
expression. In matches.hpp, you'll find lots of specializations of
detail::matches_ specified in terms of basic_expr. This works for
arbitrary expression types -- even expression extensions -- because of
the presence of the proto_base_expr and proto_grammar typedefs.

Is there some code in Proto that is forcing the instantiation of those
specializations? Probably, and that would unintended. One approach would
be to replace these normalized forms with an equivalent incomplete type
and fix all places where the code breaks.

The presence of proto_base() is also going to cause problems. It returns
the normalized form so that Proto can quickly get at child nodes. It's
also used by virtual members to build an expression on the fly. You'd
need to find equivalents for these.

I'd say, not impossible, but tricky.

Eric Niebler
BoostPro Computing
proto mailing list

Reply via email to