www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11110] New: Variant.convertsTo doesn't work like isImplicitlyConvertible

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11110

           Summary: Variant.convertsTo doesn't work like
                    isImplicitlyConvertible
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: simendsjo gmail.com


--- Comment #0 from simendsjo <simendsjo gmail.com> 2013-09-23 12:09:23 PDT ---
void main() {
    import std.variant;
    import std.stdio;
    import std.traits;

    immutable ii = 1;
    const ci = ii; // implicitly convertible
    assert(isImplicitlyConvertible!(immutable(int), const(int))); // yup
    Variant v = ii;
    assert(v.convertsTo!(const(int))); // why not?
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 23 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11110


blm768 gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |blm768 gmail.com


--- Comment #1 from blm768 gmail.com 2013-10-03 22:59:26 PDT ---
This also applies to arrays:

import std.traits;
import std.variant;

void main() {
  assert(isImplicitlyConvertible!(string, const(char)[])); //passes
  Variant var = "some_string";
  assert(var.convertsTo!(const(char)[])); //fails
}

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