Skip to content

Commit 473d5bc

Browse files
[NFC][SYCL] Drop RepeatValue helper
`vec_base` ctor already uses a private helper to pass `std::index_sequence`, no reason to go through another such helper.
1 parent aaab7e9 commit 473d5bc

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

sycl/include/sycl/detail/common.hpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -364,19 +364,6 @@ struct ArrayCreator<DataT, FlattenF> {
364364
static constexpr auto Create() { return std::array<DataT, 0>{}; }
365365
};
366366

367-
// Helper function for creating an arbitrary sized array with the same value
368-
// repeating.
369-
template <typename T, size_t... Is>
370-
static constexpr std::array<T, sizeof...(Is)>
371-
RepeatValueHelper(const T &Arg, std::index_sequence<Is...>) {
372-
auto ReturnArg = [&](size_t) { return Arg; };
373-
return {ReturnArg(Is)...};
374-
}
375-
template <size_t N, typename T>
376-
static constexpr std::array<T, N> RepeatValue(const T &Arg) {
377-
return RepeatValueHelper(Arg, std::make_index_sequence<N>());
378-
}
379-
380367
// to output exceptions caught in ~destructors
381368
#ifndef NDEBUG
382369
#define __SYCL_REPORT_EXCEPTION_TO_STREAM(str, e) \

sycl/include/sycl/vector.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ template <typename DataT, int NumElements> class vec_base {
194194
static constexpr int alignment = (std::min)((size_t)64, sizeof(DataType));
195195
alignas(alignment) DataType m_Data;
196196

197+
template <size_t... Is>
198+
constexpr vec_base(const DataT &Val, std::index_sequence<Is...>)
199+
: m_Data{((void)Is, Val)...} {}
200+
197201
template <size_t... Is>
198202
constexpr vec_base(const std::array<DataT, NumElements> &Arr,
199203
std::index_sequence<Is...>)
@@ -262,8 +266,7 @@ template <typename DataT, int NumElements> class vec_base {
262266
constexpr vec_base &operator=(vec_base &&) = default;
263267

264268
explicit constexpr vec_base(const DataT &arg)
265-
: vec_base(RepeatValue<NumElements>(arg),
266-
std::make_index_sequence<NumElements>()) {}
269+
: vec_base(arg, std::make_index_sequence<NumElements>()) {}
267270

268271
template <typename... argTN,
269272
typename = std::enable_if_t<

0 commit comments

Comments
 (0)