From 237b2d04420b38294d65a4d520c1e00e2e255e0f Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 10 Oct 2023 14:49:36 -0700 Subject: [PATCH] Adds a `static_assert` check to TrueDivideInplaceTypeMapFactory Checks that the result type is either the same as the third template parameter, or none Adds a comment to TrueDivideInplaceOutputType --- .../include/kernels/elementwise_functions/true_divide.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dpctl/tensor/libtensor/include/kernels/elementwise_functions/true_divide.hpp b/dpctl/tensor/libtensor/include/kernels/elementwise_functions/true_divide.hpp index 00a5c504e7..138f7a3f91 100644 --- a/dpctl/tensor/libtensor/include/kernels/elementwise_functions/true_divide.hpp +++ b/dpctl/tensor/libtensor/include/kernels/elementwise_functions/true_divide.hpp @@ -392,6 +392,8 @@ template struct TrueDivideInplaceFunctor }; // cannot use the out of place table, as it permits real lhs and complex rhs +// T1 corresponds to the type of the rhs, while T2 corresponds to the lhs +// the type of the result must be the same as T2 template struct TrueDivideInplaceOutputType { using value_type = typename std::disjunction< // disjunction is C++17 @@ -433,6 +435,7 @@ struct TrueDivideInplaceTypeMapFactory std::enable_if_t::value, int> get() { using rT = typename TrueDivideInplaceOutputType::value_type; + static_assert(std::is_same_v || std::is_same_v); return td_ns::GetTypeid{}.get(); } };