On Tuesday, 17 May 2016 at 17:26:59 UTC, Steven Schveighoffer
On 5/17/16 1:18 PM, Vladimir Panteleev wrote:
On Tuesday, 17 May 2016 at 14:06:37 UTC, Jack Stouffer wrote:
Thanks for writing this. Great article.
static assert(is(typeof(s.front()) == dchar));
I believe .front is a property (so some ranges can implement
it as a
field, not a @property function). Hence, no parens.
Right, but s is a string. So front is a function.
Then what happened to writing generic code?
There is an inconsistency in the compiler for this. If s.front
is a function is(typeof(s.front)) will not be what front
*returns*, but the function type itself. Unless you tag with
@property. However, it's perfectly legal for a front function
not to be tagged @property.
There is a simple answer to this, and it is to either use
ElementType or do what it does (is(typeof(R.init.front.init) T)).