Skip to content

Commit 237b2d0

Browse files
committed
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
1 parent b5c3ee7 commit 237b2d0

File tree

1 file changed

+3
-0
lines changed
  • dpctl/tensor/libtensor/include/kernels/elementwise_functions

1 file changed

+3
-0
lines changed

dpctl/tensor/libtensor/include/kernels/elementwise_functions/true_divide.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ template <typename argT, typename resT> struct TrueDivideInplaceFunctor
392392
};
393393

394394
// cannot use the out of place table, as it permits real lhs and complex rhs
395+
// T1 corresponds to the type of the rhs, while T2 corresponds to the lhs
396+
// the type of the result must be the same as T2
395397
template <typename T1, typename T2> struct TrueDivideInplaceOutputType
396398
{
397399
using value_type = typename std::disjunction< // disjunction is C++17
@@ -433,6 +435,7 @@ struct TrueDivideInplaceTypeMapFactory
433435
std::enable_if_t<std::is_same<fnT, int>::value, int> get()
434436
{
435437
using rT = typename TrueDivideInplaceOutputType<T1, T2>::value_type;
438+
static_assert(std::is_same_v<rT, T2> || std::is_same_v<rT, void>);
436439
return td_ns::GetTypeid<rT>{}.get();
437440
}
438441
};

0 commit comments

Comments
 (0)