[Issue 2733] Unclear semantics of template value parameters

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 1 05:05:34 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2733





------- Comment #3 from smjg at iname.com  2009-04-01 07:05 -------
(In reply to comment #2)
> If I want to restrict template arguments to statically known values, I can use
> a isCompileTime constraint

Templates with non-alias parameters are instantiated by value at compile-time
in the first place.  What you're proposing would be a radical change to this.

You could try defining that such a template may be instantiated either by value
or by alias.  However, this is effectively creating two mutually incompatible
templates, and it can be confusing to try to work out which is being
instantiated.

I can't think of a practical use case for passing a string by alias in a
function template, but I'm guessing there's a use for it in templates of some
kinds.  The question is whether there are enough use cases for syntactic sugar
to be worthwhile, but it could look something like
    template foo(string alias s)
....


-- 



More information about the Digitalmars-d-bugs mailing list