Skip to content

Commit 739fe76

Browse files
committed
Add assertion that index type is integral to indexing utilities
1 parent 6dc298c commit 739fe76

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <cstdint>
2929
#include <limits>
3030
#include <sycl/sycl.hpp>
31+
#include <type_traits>
3132

3233
#include "kernels/dpctl_tensor_types.hpp"
3334

@@ -46,6 +47,8 @@ namespace indexing_utils
4647

4748
template <typename IndT> struct WrapIndex
4849
{
50+
static_assert(std::is_integral_v<IndT>);
51+
4952
ssize_t operator()(ssize_t max_item, IndT ind) const
5053
{
5154
ssize_t projected;
@@ -91,6 +94,8 @@ template <typename IndT> struct WrapIndex
9194

9295
template <typename IndT> struct ClipIndex
9396
{
97+
static_assert(std::is_integral_v<IndT>);
98+
9499
ssize_t operator()(ssize_t max_item, IndT ind) const
95100
{
96101
ssize_t projected;

0 commit comments

Comments
 (0)