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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 18 22:26:05 PDT 2012


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

           Summary: [std.conv.to] constructing conversion doesn't work
                    with alias this
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2012-06-18 22:28:24 PDT ---
from
http://forum.dlang.org/thread/mailman.1606.1340038410.24740.digitalmars-d-learn@puremagic.com#post-cetlbrtfhbtunchppikq:40forum.dlang.org

----
This kind conversions should be possible with std.conv.to.

import std.conv;
struct Wrap
{
    string wrap;
    alias wrap this;
}
void main()
{
    Wrap[] y = to!(Wrap[])(["foo", "bar"]);  // shold work
}

If you can construct Wrap object with the syntax Wrap("foo"), 
std.conv.to runs 'conversion by construction'.
And if S is convertible to T, std.conv.to!(T[])(S[] source) runs 
'element-wise array conversion'.
As a result, string[] to Wrap[] will be converted.

...but, this does not work in 2.060head, it is a bug.

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