|
1 | | -.. SPDX-FileCopyrightText: 2019-2024 Intel Corporation |
| 1 | +.. SPDX-FileCopyrightText: 2019-2025 Intel Corporation |
2 | 2 | .. SPDX-FileCopyrightText: Contributors to the oneAPI Specification project. |
3 | 3 | .. |
4 | 4 | .. SPDX-License-Identifier: CC-BY-4.0 |
@@ -45,7 +45,20 @@ For example, ``blocked_nd_range<int,2>`` is analogous but not identical to ``blo |
45 | 45 | // Access |
46 | 46 | bool is_divisible() const; |
47 | 47 | const dim_range_type& dim(unsigned int dimension) const; |
48 | | - }; |
| 48 | + }; // class blocked_nd_range |
| 49 | +
|
| 50 | + // Deduction Guides |
| 51 | + template <typename Value, typename... Values> |
| 52 | + blocked_nd_range(blocked_range<Value>, blocked_range<Values>...) |
| 53 | + -> blocked_nd_range<Value, 1 + sizeof...(Values)>; |
| 54 | +
|
| 55 | + template <typename Value, unsigned int N> |
| 56 | + blocked_nd_range(const Value (&)[N], typename blocked_nd_range<Value, N>::size_type = 1) |
| 57 | + -> blocked_nd_range<Value, N>; |
| 58 | +
|
| 59 | + template <typename Value, /*a template parameter pack*/... Xs> |
| 60 | + blocked_nd_range(/*a type deducible from a braced initialization list of Value objects*/... args) |
| 61 | + -> blocked_nd_range<Value, sizeof...(args)>; // see below |
49 | 62 |
|
50 | 63 | } // namespace tbb |
51 | 64 | } // namespace oneapi |
@@ -171,9 +184,66 @@ Other dimensions and the grain sizes for each subrange remain the same as in the |
171 | 184 |
|
172 | 185 | **Returns:** ``blocked_range`` containing the value space along the dimension specified by the argument. |
173 | 186 |
|
| 187 | +Deduction Guides |
| 188 | +---------------- |
| 189 | + |
| 190 | +.. code:: cpp |
| 191 | +
|
| 192 | + template <typename Value, typename... Values> |
| 193 | + blocked_nd_range(blocked_range<Value>, blocked_range<Values>...) |
| 194 | + -> blocked_nd_range<Value, 1 + sizeof...(Values)>; |
| 195 | +
|
| 196 | +**Effects:**: Enables deduction when a set of ``blocked_range`` objects is passed to the ``blocked_nd_range`` constructor. |
| 197 | + |
| 198 | +**Constraints:**: Participates in overload resolution only if all of the types in ``Values`` are same as ``Value``. |
| 199 | + |
| 200 | +.. code:: cpp |
| 201 | +
|
| 202 | + template <typename Value, unsigned int N> |
| 203 | + blocked_nd_range(const Value (&)[N], typename blocked_nd_range<Value, N>::size_type = 1) |
| 204 | + -> blocked_nd_range<Value, N>; |
| 205 | +
|
| 206 | +**Effects:**: Enables deduction from a single C array object indicating a set of dimension sizes. |
| 207 | + |
| 208 | +.. code:: cpp |
| 209 | +
|
| 210 | + template <typename Value, /*a template parameter pack*/... Xs> |
| 211 | + blocked_nd_range(/*a type deducible from a braced initialization list of Value objects*/... args) |
| 212 | + -> blocked_nd_range<Value, sizeof...(args)>; |
| 213 | +
|
| 214 | +**Effects:**: Enables deduction when a set of ``blocked_range`` objects is provided as braced initialization lists to the ``blocked_nd_range`` constructor. |
| 215 | + |
| 216 | +.. note:: |
| 217 | + |
| 218 | + If a single braced initialization list is provided, it is interpreted as a C array of dimension sizes, not as a ``blocked_range``. |
| 219 | + |
| 220 | +**Example**: ``blocked_nd_range range({0, 10}, {0, 10, 5})`` should deduce ``range`` as ``blocked_nd_range<int, 2>``. |
| 221 | + |
| 222 | +This deduction guide should be implemented as one of the following alternatives: |
| 223 | + |
| 224 | + .. code:: cpp |
| 225 | +
|
| 226 | + template <typename Value, typename... Values> |
| 227 | + blocked_nd_range(std::initializer_list<Value>, std::initializer_list<Values>...) |
| 228 | + -> blocked_nd_range<Value, 1 + sizeof...(Values)>; |
| 229 | +
|
| 230 | + **Constraints:** Participates in overload resolution only if ``sizeof...(Values) > 0`` and all types in ``Values`` are the same as ``Value``. |
| 231 | + |
| 232 | +or |
| 233 | + |
| 234 | + .. code:: cpp |
| 235 | +
|
| 236 | + template <typename Value, unsigned int... Ns> |
| 237 | + blocked_nd_range(const Value (&... dim)[Ns]) |
| 238 | + -> blocked_nd_range<Value, sizeof...(Ns)>; |
| 239 | +
|
| 240 | + **Constraints:** Participates in overload resolution only if ``sizeof...(Ns) > 1`` and ``N == 2`` or ``N == 3`` for each ``N`` in ``Ns``. |
| 241 | + |
| 242 | +In addition to the explicit deduction guides above, the implementation shall provide implicit or explicit deduction guides for copy constructor, |
| 243 | +move constructor and constructors taking ``split`` and ``proportional_split`` arguments. |
| 244 | + |
174 | 245 | See also: |
175 | 246 |
|
176 | 247 | * :doc:`blocked_range <blocked_range_cls>` |
177 | 248 | * :doc:`blocked_range2d <blocked_range2d_cls>` |
178 | 249 | * :doc:`blocked_range3d <blocked_range3d_cls>` |
179 | | - |
|
0 commit comments