SpECTRE Documentation Coverage Report
Current view: top level - Utilities/TypeTraits - HasEquivalence.hpp Hit Total Coverage
Commit: 5f37f3d7c5afe86be8ec8102ab4a768be82d2177 Lines: 3 4 75.0 %
Date: 2024-04-26 23:32:03
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14