Listing 1: GN’s specialization for unary functions

template <typename R, typename A>
struct GN<R (A)> {
    typedef R RetType;
    typedef A ArgType;
    typedef R FuncType( A );
    enum {
        // calculate how much to shift ret and arg
        argshift = ArglenLen+ArgcountLen+ModLen,
        arglen = GN<ArgType>::len,
        retshift = arglen+argshift,

        // get code for return type
        r1 = GN<RetType>::code1,
        r2 = GN<RetType>::code2,
        r3 = GN<RetType>::code3,
        r4 = GN<RetType>::code4,
        retlen = GN<RetType>::len,
        
        // get code for arg type
        a1 = GN<ArgType>::code1,
        a2 = GN<ArgType>::code2,
        a3 = GN<ArgType>::code3,
        a4 = GN<ArgType>::code4,
        
        // shift arg type
        sa4 = ShiftLeft<a4,a3,a2,a1,argshift>::code4,
        sa3 = ShiftLeft<a4,a3,a2,a1,argshift>::code3,
        sa2 = ShiftLeft<a4,a3,a2,a1,argshift>::code2,
        sa1 = ShiftLeft<a4,a3,a2,a1,argshift>::code1,
        
        // shift return type
        sr4 = ShiftLeft<r4,r3,r2,r1,retshift>::code4,
        sr3 = ShiftLeft<r4,r3,r2,r1,retshift>::code3,
        sr2 = ShiftLeft<r4,r3,r2,r1,retshift>::code2,
        sr1 = ShiftLeft<r4,r3,r2,r1,retshift>::code1,
        
        // paste everything together
        code4 = sr4 | sa4,
        code3 = sr3 | sa3,
        code2 = sr2 | sa2,
        // note assumption below that ArgcountLen+Modlen
        //    < number of bits in Code!
        code1 = sr1 | sa1 | (arglen<<(ArgcountLen+ModLen))
                    | (1<<ModLen) | Fun,
        
        // calculate total length
        len = retlen+arglen+ArglenLen+ArgcountLen+ModLen
    };
    // check for overflow
    GODEL_NUMBER_LENGTH_CHECK(len);
};