Why is equality checked twice in same_as?

Viewed 60

Looking the "possible" implementation section of std::same_as something strikes me as odd:

namespace detail {
    template< class T, class U >
    concept SameHelper = std::is_same_v<T, U>;
}
 
template< class T, class U >
concept same_as = detail::SameHelper<T, U> && detail::SameHelper<U, T>;

The check for type equality is done twice, once as T==U and the second as U==T. Given that equailty is symmetric by nature, why is the extra check needed?

0 Answers
Related