W3cubDocs

/C++

std::Same

Defined in header <concepts>
template < class T, class U >
concept Same = std::is_same_v<T, U>;
(since C++20)

The concept Same<T, U> is satisfied if and only if T and U denote the same type.

std::Same<T, U> subsumes std::Same<U, T> and vice versa.

Possible implementation

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

See also

(C++11)
checks if two types are the same
(class template)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/concepts/Same