Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1556

Show
Ignore:
Timestamp:
05/26/10 05:59:40 (15 years ago)
Author:
rsinfu
Message:

Removed ref return attribute from toDelegate().
It's indeed reasonable to make the parameter auto ref because fp can be a structure with opCall since r1528. But ref return is not necessary for toDelegate() itself.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phobos/std/functional.d

    r1528 r1556  
    538538 * void runDelegate(void delegate() myDelegate) { 
    539539 *     myDelegate(); 
    540540 * } 
    541541 * 
    542542 * auto delegateToPass = toDelegate(&doStuff); 
    543543 * runDelegate(delegateToPass);  // Calls doStuff, prints "Hello, world." 
    544544 * --- 
    545545 * 
    546546 * Bugs:  Doesn't work properly with ref return.  (See DMD bug 3756.) 
    547547 */ 
    548 auto ref toDelegate(F)(auto ref F fp) if (isCallable!(F)) { 
     548auto toDelegate(F)(auto ref F fp) if (isCallable!(F)) { 
    549549 
    550550    static if (is(F == delegate)) 
    551551    { 
    552552        return fp; 
    553553    } 
    554554    else static if (is(typeof(&F.opCall) == delegate) 
    555555                || (is(typeof(&F.opCall) V : V*) && is(V == function))) 
    556556    { 
    557557        return toDelegate(&fp.opCall); 
    558558    }