<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 24 July 2014 16:02, anonymous via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thursday, 24 July 2014 at 04:53:41 UTC, Manu via Digitalmars-d<br>
wrote:<div class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
struct S(size_t len = 10)<br>
{<br>
  ubyte[len] data;<br>
}<br>
<br>
S!100 x; // this works fine<br>
S y; // this doesn't work (!)<br>
S!() z; // this works<br>
<br>
The template arg has a default arg, why require !() ??<br>
</blockquote>
<br></div>
So that the type S!() is (easily) distinguishable from the<br>
template S.</blockquote><div><br></div><div>Hmm.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This causes problems in meta code, where you want to create an instance of<br>
some T, and T may be a normal type with no template args, in which case !()<br>
is invalid, but a template type with default args should also be<br>
acceptable, but it doesn't work because the meta code doesn't specify !().<br>
</blockquote>
<br></div>
Add !() at the instantiation site.</blockquote><div><br></div><div>Then the code is broken for any type that isn't a template... it's a mutually exclusive situation.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
struct S(T)<br>
{<br>
  this(T t)<br>
  {<br>
    m = t;<br>
  }<br>
<br>
  T m;<br>
}<br>
<br>
int myThing;<br>
auto s = S(myThing); // error!<br>
auto s = S!(typeof(myThing))(myThing); // works, but horrible, and breaks<br>
down again when used in place of non-template counterparts in meta code.<br>
</blockquote>
<br></div>
Phobos goes with helper functions: S!T s(T)(T t) {return S!T(t);}<br>
I'm not a fan either.<br>
</blockquote></div><br></div><div class="gmail_extra">Why? Surely this is easy to implement?</div></div>