DIP66 - Multiple alias this
Meta via Digitalmars-d
digitalmars-d at puremagic.com
Tue Oct 28 14:55:33 PDT 2014
On Tuesday, 28 October 2014 at 20:09:07 UTC, IgorStepanov wrote:
> And please comment my way to resolving "is" expression via
> alias-this:
> http://forum.dlang.org/thread/ubafmwvxwtolhmnxbrsf@forum.dlang.org?page=5
Something else related to the discussion about `is` from this
thread:
http://forum.dlang.org/post/tulvmydnogbgebnxybfk@forum.dlang.org.
The following code:
import std.math;
import std.traits;
struct S(T)
if(isFloatingPoint!T)
{
T val;
alias val this;
}
void main()
{
auto s = S!float();
assert(isNaN(s));
s = 10.0;
assert(!isNaN(s));
}
Current fails to compile with this error:
Error: template std.math.isNaN cannot deduce function from
argument types !()(S!float), candidates are:
std/math.d(4171): std.math.isNaN(X)(X x) if
(isFloatingPoint!X)
Is this a problem with the current implementation of `alias
this`, or should isFloatingPoint be changed so that it also
accepts types that alias a floating point type?
More information about the Digitalmars-d
mailing list