Andrei Alexandrescu Wrote:
> 
> One question that bugs me is, where do you draw the line? Say there's a 
> metaprogramming problem at hand. How to decide on solving it with CTFE 
> vs. solving it with templates? It would be great to have a simple 
> guideline that puts in contrast the pluses and minuses of the two 
> approaches.
> 
> It is quite possible that templates get relegated to parameterized 
> functions and types, whereas all heavy lifting in metaprogramming should 
> be carried with CTFE.

That would certainly be my preferred division. Templates can be used as a 
replacement for interfaces when the overhead can't be tolerated. D's ranges 
make heavy use of this. Templates can avoid virtual function calls and keep 
object size small. Having abused this a bit too much, I'd love to be able to 
template modules... import whatever!(int) : foo, bar, baz;

Reply via email to