return in void functions

BCS ao at pathlink.com
Wed Mar 4 14:19:38 PST 2009


Reply to bearophile,


> But this compiles with no errors:
> 
> void foo() {
> return 1;
> }
> void main() {
> foo();
> }

IIRC D allows "return exp;" in a void function because it avoids special 
cases in template code.

ReturnTypeOf!(AFn, T) fn(T)(T t)
{
    return AFn(t,t); // AFn might return void
}





More information about the Digitalmars-d mailing list