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 #include "Utilities/TypeTraits.hpp"
10 
11 namespace tt {
12 // @{
13 /// \ingroup TypeTraitsGroup
14 /// \brief Determines if a type `T` is a `std::complex` of a fundamental type,
15 /// is a `std::true_type` if so, and otherwise is a `std::false_type`
16 ///
17 /// \snippet Test_IsComplexOfFundamental.cpp is_complex_of_fundamental
18 template <typename T, typename = cpp17::bool_constant<true>>
20 
21 /// \cond
22 // this version will only pattern match if `T` is both complex and a fundamental
23 // type
24 template <typename T>
26  std::complex<T>, cpp17::bool_constant<cpp17::is_fundamental_v<T>>>
27  : std::true_type {};
28 /// \endcond
29 // @}
30 
31 template <typename T>
32 constexpr bool is_complex_of_fundamental_v =
34 
35 /// \ingroup TypeTraitsGroup
36 /// \brief Evaluates to `true` if type `T` is a `std::complex` of a fundamental
37 /// type or if `T` is a fundamental type.
38 template <typename T>
40  is_complex_of_fundamental_v<T> or cpp17::is_fundamental_v<T>;
41 } // namespace tt
A collection of useful type traits.
Definition: TensorExpression.hpp:113
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:39
Determines if a type T is a std::complex of a fundamental type, is a std::true_type if so...
Definition: IsComplexOfFundamental.hpp:19