[Issue 13196] Infer struct/class template args from constructor args

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jul 23 22:47:40 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13196

Jakob Ovrum <jakobovrum at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jakobovrum at gmail.com
         Resolution|---                         |DUPLICATE

--- Comment #1 from Jakob Ovrum <jakobovrum at gmail.com> ---
This has been discussed before, and there is even a DIP for it. See #6082.

It's not so easy to do in the general case:

---
struct S(T)
{
    static if(is(T == bool))
    {
        this(T[] t) {}
    }
    else
    {
        this(int i) {}
    }
}

auto s = S([true, false]);
auto s2 = S(2);
---

How do you propose we deduce T for the above two?

*** This issue has been marked as a duplicate of issue 6082 ***

--


More information about the Digitalmars-d-bugs mailing list