www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6322] New: IFTI doesn't support static arrays

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

           Summary: IFTI doesn't support static arrays
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com



---
Maybe it duplicates some other issue, but I didn't find it.
Or maybe it is issue 2296.

void f(T: T[n], size_t n)(T[n] t) { }

void main()
{
    int[2] a;
    f!(typeof(a))(a); //this compiles
    f(a); //this doesn't
}

main.d(7): Error: template main.f(T : T[n],uint n) does not match any function
template declaration
main.d(7): Error: template main.f(T : T[n],uint n) cannot deduce template
function from argument types !()(int[2u])

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 15 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6322


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
                 CC|                            |yebblies gmail.com
           Platform|Other                       |All
         OS/Version|Windows                     |All



void f(T: U[n], U, size_t n)(T t) { } works as a substitute.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 15 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6322




---
Another workaround is D2 constraints (more powerful and less buggly):

import std.traits;
void f(Tn)(Tn t) if(isStaticArray!Tn) { }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 15 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6322


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




 void f(T: T[n], size_t n)(T[n] t) { }
 
 void main()
 {
     int[2] a;
     f!(typeof(a))(a); //this compiles
     f(a); //this doesn't
 }
The template function never called with IFTI, because: 1. T is deduced to int from the argument 'a'. 2. T is tested with specialized signature `: T[n]`. But T is int, so never match. Although it looks weird behavior, it is not a bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 08 2013