SpECTRE
v2021.01.11
Documentation
Introduction
Releases
Installation
User Tutorials
Dev Guide
Code of Conduct
Contributing Guide
Code Reference
Topics
Namespaces
Files
Bibliography
View on GitHub
src
Utilities
TypeTraits
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
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
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
constexpr
bool
has_equivalence_v
=
has_equivalence<T>::value
;
53
54
/// \see has_equivalence
55
template
<
typename
T>
56
using
has_equivalence_t
=
typename
has_equivalence<T>::type
;
57
// @}
58
}
// namespace tt
std::false_type
tt::has_equivalence_t
typename has_equivalence< T >::type has_equivalence_t
Definition:
HasEquivalence.hpp:56
tt::has_equivalence_v
constexpr bool has_equivalence_v
Definition:
HasEquivalence.hpp:52
tt::has_equivalence
Check if type T has operator== defined.
Definition:
HasEquivalence.hpp:41
tt
Definition:
TensorExpression.hpp:141
type_traits
© Copyright 2017 - 2020
SXS Collaboration
,
Distributed under the
MIT License