IsComplexOfFundamental.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <complex>
7 #include <type_traits>
8 
9 namespace tt {
10 // @{
11 /// \ingroup TypeTraitsGroup
12 /// \brief Determines if a type `T` is a `std::complex` of a fundamental type,
13 /// is a `std::true_type` if so, and otherwise is a `std::false_type`
14 ///
15 /// \snippet Test_IsComplexOfFundamental.cpp is_complex_of_fundamental
16 template <typename T, typename = std::bool_constant<true>>
18 
19 /// \cond
20 // this version will only pattern match if `T` is both complex and a fundamental
21 // type
22 template <typename T>
23 struct is_complex_of_fundamental<std::complex<T>,
24  std::bool_constant<std::is_fundamental_v<T>>>
25  : std::true_type {};
26 /// \endcond
27 // @}
28 
29 template <typename T>
30 constexpr bool is_complex_of_fundamental_v =
31  is_complex_of_fundamental<T>::value;
32 
33 /// \ingroup TypeTraitsGroup
34 /// \brief Evaluates to `true` if type `T` is a `std::complex` of a fundamental
35 /// type or if `T` is a fundamental type.
36 template <typename T>
38  is_complex_of_fundamental_v<T> or std::is_fundamental_v<T>;
39 } // namespace tt
std::false_type
tt::is_complex_of_fundamental
Determines if a type T is a std::complex of a fundamental type, is a std::true_type if so,...
Definition: IsComplexOfFundamental.hpp:17
tt
Definition: TensorExpression.hpp:113
complex
tt::is_complex_or_fundamental_v
constexpr bool is_complex_or_fundamental_v
Evaluates to true if type T is a std::complex of a fundamental type or if T is a fundamental type.
Definition: IsComplexOfFundamental.hpp:37
type_traits