Jeremie Pelletier wrote:
Andrei Alexandrescu wrote:
Daniel Keep wrote:
Andrei Alexandrescu wrote:
Daniel Keep wrote:
P.S. And another thing while I'm at it: why can't we declare void
variables? This is another thing that really complicates generic code.
How would you use them?


Andrei

Here's an OLD example:

ReturnType!(Fn) glCheck(alias Fn)(ParameterTypeTuple!(Fn) args)
{
    alias ReturnType!(Fn) returnT;

    static if( is( returnT == void ) )
        Fn(args);
    else
        auto result = Fn(args);

    glCheckError();

    static if( !is( returnT == void ) )
        return result;
}

This function is used to wrap OpenGL calls so that error checking is
performed automatically.  Here's what it would look like if we could use
void variables:

ReturnType!(Fn) glCheck(alias Fn)(ParameterTypeTuple!(Fn) args)
{
    auto result = Fn(args);

    glCheckError();

    return result;
}

ReturnType!(Fn) glCheck(alias Fn)(ParameterTypeTuple!(Fn) args)
{
    scope(exit) glCheckError();
    return Fn(args);
}

:o)


Andrei

Calling into a framehandler for such a trivial routine, especially if used with real time rendering, is definitely not a good idea, no matter how elegant its syntax is!

I guess that's what the smiley was about!

Andrei

Reply via email to