HasEquivalence.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <type_traits>
7 
8 #include "Utilities/TypeTraits.hpp"
9 
10 namespace tt {
11 // @{
12 /// \ingroup TypeTraitsGroup
13 /// \brief Check if type `T` has operator== defined.
14 ///
15 /// \details
16 /// Inherits from std::true_type if the type `T` has operator== defined,
17 /// otherwise inherits from std::false_type
18 ///
19 /// \usage
20 /// For any type `T`,
21 /// \code
22 /// using result = tt::has_equivalence<T>;
23 /// \endcode
24 ///
25 /// \metareturns
26 /// cpp17::bool_constant
27 ///
28 /// \semantics
29 /// If the type `T` has operator== defined, then
30 /// \code
31 /// typename result::type = std::true_type;
32 /// \endcode
33 /// otherwise
34 /// \code
35 /// typename result::type = std::false_type;
36 /// \endcode
37 ///
38 /// \example
39 /// \snippet Test_HasEquivalence.cpp has_equivalence_example
40 /// \see has_inequivalence
41 /// \tparam T the type we want to know if it has operator==
42 template <typename T, typename = cpp17::void_t<>>
44 
45 /// \cond HIDDEN_SYMBOLS
46 template <typename T>
47 struct has_equivalence<
48  T, cpp17::void_t<decltype(std::declval<T>() == std::declval<T>())>>
49  : std::true_type {};
50 /// \endcond
51 
52 /// \see has_equivalence
53 template <typename T>
55 
56 /// \see has_equivalence
57 template <typename T>
59 // @}
60 } // namespace tt
Check if type T has operator== defined.
Definition: HasEquivalence.hpp:43
void void_t
Given a set of types, returns void
Definition: TypeTraits.hpp:187
A collection of useful type traits.
Definition: TensorExpression.hpp:113
typename has_equivalence< T >::type has_equivalence_t
Definition: HasEquivalence.hpp:58
constexpr bool has_equivalence_v
Definition: HasEquivalence.hpp:54