Skip to content

Commit 1110b0c

Browse files
committed
Add single C array support
1 parent 3935022 commit 1110b0c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

include/oneapi/tbb/blocked_nd_range.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class blocked_nd_range : public blocked_nd_range_impl<Value, N> {
151151
// blocked_nd_range(const dim_range_type& dim0, const dim_range_type& dim1, ...)
152152
// while the arguments are passed as braced-init-lists
153153
// Works only for 2 and more arguments since the deduction from
154-
// single braced-init-list argument is ambiguous with the single C-array argument
154+
// single braced-init-list or single C-array argument prefers the multi-dimensional range
155155
// Only braced-init-lists of size 2 and 3 are allowed since dim_range_type may only
156156
// be constructed from 2 or 3 arguments
157157
template <typename Value, unsigned int... Ns,
@@ -168,18 +168,8 @@ blocked_nd_range(blocked_range<Value>, blocked_range<Values>...)
168168
-> blocked_nd_range<Value, 1 + sizeof...(Values)>;
169169

170170
// blocked_nd_range(const value_type (&size)[N], size_type grainsize = 1)
171-
// while the grainsize is not passed
172-
// Does not work for arrays of size 2 or 3 since it is ambiguous with deducing
173-
// for dim_range_type constructor taking the single braced-init-list
174-
template <typename Value, unsigned int N,
175-
typename = std::enable_if_t<(N != 2 && N != 3)>>
176-
blocked_nd_range(const Value (&)[N])
177-
-> blocked_nd_range<Value, N>;
178-
179-
// blocked_nd_range(const value_type (&size)[N], size_type grainsize = 1)
180-
// while using the non-default grainsize
181171
template <typename Value, unsigned int N>
182-
blocked_nd_range(const Value (&)[N], typename blocked_nd_range<Value, N>::size_type)
172+
blocked_nd_range(const Value (&)[N], typename blocked_nd_range<Value, N>::size_type = 1)
183173
-> blocked_nd_range<Value, N>;
184174

185175
// blocked_nd_range(blocked_nd_range<Value, N>&, oneapi::tbb::split)

test/tbb/test_blocked_range.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ void test_deduction_guides() {
244244
blocked_nd_range range({T{100}, T{200}}, 5);
245245
static_assert(std::is_same_v<decltype(range), blocked_nd_range<T, 2>>);
246246
}
247+
{
248+
blocked_nd_range range({T{100}, T{200}});
249+
static_assert(std::is_same_v<decltype(range), blocked_nd_range<T, 2>>);
250+
}
247251
{
248252
T array[2] = {100, 200};
249253
blocked_nd_range range(array, 5);
@@ -253,6 +257,10 @@ void test_deduction_guides() {
253257
blocked_nd_range range({T{100}, T{200}, T{300}}, 5);
254258
static_assert(std::is_same_v<decltype(range), blocked_nd_range<T, 3>>);
255259
}
260+
{
261+
blocked_nd_range range({T{100}, T{200}, T{300}});
262+
static_assert(std::is_same_v<decltype(range), blocked_nd_range<T, 3>>);
263+
}
256264
{
257265
T array[3] = {100, 200, 300};
258266
blocked_nd_range range(array, 5);

0 commit comments

Comments
 (0)