Skip to content

Add support of CV-qualifiers in is_complex<T> helper #1900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fix warning in documentation generation caused by `diff` docstring [gh-1855](https://github.com/IntelPython/dpctl/pull/1855)
* Fix additional warnings when generating docs [gh-1861](https://github.com/IntelPython/dpctl/pull/1861)
* Add missing include of SYCL header to "math_utils.hpp" [gh-1899](https://github.com/IntelPython/dpctl/pull/1899)
* Add support of CV-qualifiers in `is_complex<T>` helper [gh-1900](https://github.com/IntelPython/dpctl/pull/1900)

## [0.18.1] - Oct. 11, 2024

Expand Down
14 changes: 12 additions & 2 deletions dpctl/tensor/libtensor/include/utils/type_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <complex>
#include <stdexcept>
#include <sycl/sycl.hpp>
#include <type_traits>
#include <utility>

namespace dpctl
Expand All @@ -35,13 +36,22 @@ namespace tensor
namespace type_utils
{

template <class T> struct is_complex : std::false_type
template <typename T, typename = void>
struct is_complex : public std::false_type
{
};
template <class T> struct is_complex<std::complex<T>> : std::true_type

template <typename T>
struct is_complex<
T,
std::enable_if_t<std::is_same_v<std::remove_cv_t<T>, std::complex<float>> ||
std::is_same_v<std::remove_cv_t<T>, std::complex<double>>>>
: public std::true_type
{
};

template <typename T> constexpr bool is_complex_v = is_complex<T>::value;

template <typename dstTy, typename srcTy> dstTy convert_impl(const srcTy &v)
{
if constexpr (std::is_same<dstTy, srcTy>::value) {
Expand Down
Loading