[Issue 12466] New: Template type parameter should not require a new symbol for deducing a type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 25 09:55:32 PDT 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12466

           Summary: Template type parameter should not require a new
                    symbol for deducing a type
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2014-03-25 17:55:29 CET ---
-----
void foo(Array : C[N], C, size_t N)(Array array) { }

void bar(C[N], C, size_t N)(C[N] array) { }  // NG

void main()
{
    char[2] arr;
    foo(arr);  // ok
    bar(arr);  // NG in declaration
}
-----

$ dmd test.d
> Error: identifier expected for template value parameter

This is a little bit inconsistent with how is() already works. The following is
currently allowed:

-----
void main()
{
    char[2] arr;

    {
    // ok
    static if (is(typeof(arr) Array : A[N], A, size_t N))
    {
        pragma(msg, Array);  // char[2]
    }
    }

    {
    // also ok
    static if (is(typeof(arr) /* Array */: A[N], A, size_t N))
    {
        pragma(msg, A[N]);  // char[2]
    }
    }
}
-----

Therefore I think we should also allow it in a template (function) declaration
as well.

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


More information about the Digitalmars-d-bugs mailing list