[Issue 9151] opCast makes "this" alias ineffective

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 13 22:16:06 PST 2012


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



--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2012-12-13 22:16:00 PST ---
(In reply to comment #0)
> The following code gives me an error saying:
> Error: template instance opCast!(bool) opCast!(bool) does not match template
> declaration opCast(T)() if (is(T == int))

(In reply to comment #0)
> The following code gives me an error saying:
> Error: template instance opCast!(bool) opCast!(bool) does not match template
> declaration opCast(T)() if (is(T == int))

This is an intended behavior.

1. In IfStatement, opCast!bool is implicitly used.
   http://dlang.org/operatoroverloading#Cast

2. alias this works just like a class inheritance.
   If the derived type (== Foo) defines opCast, compiler does not look up
   the base type opCast (== implicit conversion from int to bool)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list