IMHO that's awfully constructed statement over there, it's unreadable. But it can be "disassembled" hierarchically:
template <typename C>
static yes & f (
typename std::enable_if<
std::is_same<
decltype(
static_cast<
typename C::const_iterator(C::*)() const
>(&C::begin)
),
typename C::const_iterator(C::*)() const
>::value
>::type *
);
It declares a template with class parameter C of function f
that returns yes&
.
The function instance will have a parameter of type void*
if typename C::const_iterator(C::*)() const
and the type of result of cast of &C::begin
to C::const_iterator(C::*)() const
are same, otherwise the template won't produce legal instance due to SFINAE, because std::enable_if<>::type
won't be declared (std::enable_if<expr>::type
defaults to void
if expr
is true)
typename C::const_iterator(C::*)() const
is a pointer to member of class C with signature similar to
C::const_iterator name () const
, i.e. it returns C::const_iterator
, takes no parameters, and is a const member. In standard prior to C++20 you have to use typename
if declaration depends on template parameter, it seems that requirement is proposed to be lifted in latest standard.
static_cast<typename C::const_iterator(C::*)() const>
is there likely to protect from case when C::begin
is an overloaded function member, it would choose the proper overload.