Skip to content

Commit 6250841

Browse files
committed
Align is_complex<T> implementation with STL wrappers of DPC++ compiler
1 parent 3d5ef0a commit 6250841

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

dpctl/tensor/libtensor/include/utils/type_utils.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,22 @@ namespace tensor
3535
namespace type_utils
3636
{
3737

38-
template <class T> struct is_complex : std::false_type
38+
template <typename T, typename = void>
39+
struct is_complex : public std::false_type
3940
{
4041
};
41-
template <class T> struct is_complex<std::complex<T>> : std::true_type
42+
43+
template <typename T>
44+
struct is_complex<T, std::enable_if_t<std::is_same_v<std::remove_cv_t<T>, std::complex<sycl::half>> ||
45+
std::is_same_v<std::remove_cv_t<T>, std::complex<float>> ||
46+
std::is_same_v<std::remove_cv_t<T>, std::complex<double>>>>
47+
: public std::true_type
4248
{
4349
};
4450

51+
template <typename T>
52+
constexpr bool is_complex_v = is_complex<T>::value;
53+
4554
template <typename dstTy, typename srcTy> dstTy convert_impl(const srcTy &v)
4655
{
4756
if constexpr (std::is_same<dstTy, srcTy>::value) {

0 commit comments

Comments
 (0)