[Issue 8264] [std.conv.to] constructing conversion doesn't work with alias this

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 18 23:14:34 PDT 2012


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



--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2012-06-18 23:16:52 PDT ---
(In reply to comment #1)
> Is it really bug?

Yes. The problem is that declaring alias this is incorrectly matches more than
two templates. If you remove 'alias wrap this' from Wrap type, the conversion
will succeed.

> What if you have
> 
> struct Wrap
> {
>     string wrap;
>     int i;
>     double d;
>     string s;
> 
>     alias wrap this;
> }
> 
> Should Wrap("foo") create the same thing as Wrap("foo", int.init, double.init,
> string.init)? Or should it not work? Maybe it should work, but it seems a bit
> funny to me to create a Wrap from just a string considering that the alias
> doesn't define how to initialize the rest of the object.

I also it seems a bit funny, but it should work.
std.conv.to supports constructing conversion based on _syntactic possibilities_
- like range interface: r.empty, r.front, and r.popFront().
I think such limitation provides no benefit.

-- 
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