www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3756] New: std.traits.ReturnType broken for ref returns

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

           Summary: std.traits.ReturnType broken for ref returns
           Product: D
           Version: 2.040
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com


--- Comment #0 from David Simcha <dsimcha yahoo.com> 2010-01-30 15:54:58 PST ---
import std.traits;

ref uint foo(ref uint num) {
    return num;
}

pragma(msg, ReturnType!(foo));  // uint, not ref uint.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 30 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3756


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |FIXED


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-21
07:30:46 PST ---
Type modifiers can't be passed around in the language, but I think there's a
separate issue already opened for this.

Anyway you can do:

import std.traits;

ref uint foo(ref uint num) {
    return num;
}

void main()
{
    alias FunctionAttribute FA;
    static assert(functionAttributes!foo & FA.ref_);
}

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