jeudi 6 septembre 2018

What does '->' mean after a function declaration in C++ 11? [duplicate]

This question already has an answer here:

What is the syntax used here with '-> decltype' after the operator() signature and what is it for?

template<>
struct less<void>
{   // transparent functor for operator<
typedef int is_transparent;

template<class _Ty1,
    class _Ty2>
    constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const
    -> decltype(static_cast<_Ty1&&>(_Left)
        < static_cast<_Ty2&&>(_Right))
    {   // transparently apply operator< to operands
    return (static_cast<_Ty1&&>(_Left)
        < static_cast<_Ty2&&>(_Right));
    }
};

this is the code from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\xstddef line 276.

Why are the following two lines duplicated?

(static_cast<_Ty1&&>(_Left)
        < static_cast<_Ty2&&>(_Right))

Aucun commentaire:

Enregistrer un commentaire