mercredi 28 juin 2017

Warning: function uses 'auto' type specifier without trailing return type

The following code gives the warning below. Can someone please explain why (note the code is not useful as is as I replaced my types with int to make a complete example).

warning: 'MaxEventSize()' function uses 'auto' type specifier without trailing return type [enabled by default]

The idea is to get the maximum size of a particular structure (types go where int is).

template<typename T>
constexpr T cexMax(T a, T b)
{
    return (a < b) ? b : a;
}

constexpr auto MaxEventSize()
{
    return cexMax(sizeof(int),
           cexMax(sizeof(int),
                    sizeof(int)));
};

Aucun commentaire:

Enregistrer un commentaire