Problem with ReturnType
    Kirk McDonald 
    kirklin.mcdonald at gmail.com
       
    Fri Apr  4 12:43:29 PDT 2008
    
    
  
bearophile wrote:
> After an 1+ hours long bug hunt, I have reduced my code to the following one.
> ReturnType below is a reduced version of std.traits.ReturnType:
> 
> template ReturnType(T) {
>     static if (is(T R == return))
>         alias R ReturnType;
> }
> 
> void bar(T)(T f) { return f(); }
> 
> void main() {
>     alias ReturnType!( typeof( (int x){ return x; } ) ) TInt; //problem
>     bar((int n=1) { return 2; });
> }
> 
> The output:
> test.d(6): Error: expected 1 arguments, not 0
> test.d(10): template instance test.bar!(int delegate(int x)) error instantiating
> 
> Is this a bug of DMD/Phobos (I am using 1.028)?
> 
> Bye,
> bearophile
Delegates can't have default arguments.
-- 
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org
    
    
More information about the Digitalmars-d-learn
mailing list