Thread overview
[Issue 4215] New: auto ref parameters don't work with class template variables
May 20, 2010
Trass3r
May 21, 2010
Walter Bright
May 21, 2010
Trass3r
May 21, 2010
Trass3r
May 21, 2010
Walter Bright
May 20, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4215

           Summary: auto ref parameters don't work with class template
                    variables
           Product: D
           Version: 2.038
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: mrmocool@gmx.de


--- Comment #0 from Trass3r <mrmocool@gmx.de> 2010-05-20 15:35:34 PDT ---
Something like

class Foo(T)
{
    void bar(auto ref T item)
    {
    }
}

doesn't work.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4215


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2010-05-20 22:20:48 PDT ---
Exactly what does it do that is wrong?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4215


Trass3r <mrmocool@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


--- Comment #2 from Trass3r <mrmocool@gmx.de> 2010-05-21 05:12:20 PDT ---
class Foo(T)
{
    void bar(auto ref T item)
    {
    }
}

void main()
{
    Foo!(int) f;
}

gives

test.d(3): Error: auto can only be used for template function parameters

Hmm ok, maybe it rather is an enhancement.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4215



--- Comment #3 from Trass3r <mrmocool@gmx.de> 2010-05-21 05:28:54 PDT ---
the more general code:

template bar(T)
{
    void bar(auto ref T item)
    {
    }
}

void main()
{
    bar!(int) f;
}

also doesn't work.


Even the following doesn't compile:
void bar(T)(auto ref T item)
{
}

void main()
{
    int i;
    bar!(int)(i); // while bar(i); is OK
}
test.d(1): Error: auto can only be used for template function parameters
test.d(8): Error: template instance test.bar!(int) error instantiating

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4215



--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2010-05-21 09:49:12 PDT ---
What semantics do you wish auto to have for parameters? i.e. why are you using it?

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