jeudi 28 juillet 2016

Trailing return type vs. templated return type [duplicate]

Consider the following class.

template<class T>
struct Foo
{
    Foo()
    {
    }

    auto bar() const -> typename T::bar_t
    {
        return typename T::bar_t();
    }
};

The above bar() method could also be implemented like below.

typename T::bar_t bar() const
{
    return typename T::bar_t();
}

Is there any difference between these two methods? How would each of these functions be implemented internally? Is one more efficient or preferable than the other?

Aucun commentaire:

Enregistrer un commentaire