diff --git a/P0009/wg21/data/index.yaml b/P0009/wg21/data/index.yaml index f321068a..636d3d2e 100644 --- a/P0009/wg21/data/index.yaml +++ b/P0009/wg21/data/index.yaml @@ -83180,7 +83180,14 @@ references: - family: H. Carter Edwards, Bryce Adelstein Lelbach, Daniel Sunderland, David Hollman, Christian Trott, Mauro Bianco, Ben Sander, Athanasios Iliopoulos, John Michopoulos, Mark Hoemmen issued: year: 2019 - URL: https://wg21.link/p0009r9 + - id: P0009R18 + citation-label: P0009R18 + title: "mdspan" + author: + - family: Christian Trott, D.S. Hollman, Damien Lebrun-Grandie, Mark Hoemmen, Daniel Sunderland, H. Carter Edwards, Bryce Adelstein Lelbach, Mauro Bianco, Ben Sander, Athanasios Iliopoulos, John Michopoulos, Nevin Liber + issued: + year: 2022 + URL: https://wg21.link/p0009r18 - id: P0010R0 citation-label: P0010R0 title: "Adding a subsection for concurrent random number generation in C++17" diff --git a/P1684-mdarray/P1684.html b/P1684-mdarray/P1684.html index 6225b431..ae7b4070 100644 --- a/P1684-mdarray/P1684.html +++ b/P1684-mdarray/P1684.html @@ -4,7 +4,7 @@ - +
mdarray: An
[P0009R18?] proposed
-mdspan, a nonowning multidimensional array abstraction. It
-was voted into the C++23 draft. This proposal builds on
-mdspan by introducing mdarray, an
-owning multidimensional array that interoperates with
-mdspan. The mdarray class is to
-vector as mdspan is to span.
-Owning semantics can make it easier for users to express common cases,
-like returning an array from a function. It also makes it much easier to
-create a multi dimensional array for use:
[P0009R18] proposed mdspan,
+a nonowning multidimensional array abstraction. It was voted into the
+C++23 draft. This proposal builds on mdspan by introducing
+mdarray, an owning multidimensional array that
+interoperates with mdspan. The mdarray class
+is to vector as mdspan is to
+span. Owning semantics can make it easier for users to
+express common cases, like returning an array from a function. It also
+makes it much easier to create a multi dimensional array for use:
C++23:
-// Create a mapping so one knows how many +, so an entirely reasonable outcome would be to have:// Create a mapping so one knows how many // elements the buffer needs to have layout_right::mapping<dextents<int, 2>> map(N,M); @@ -626,9 +625,9 @@3 Des the design of
mdspanas much as possible, with the goals of reducing cognitive load for users already familiar withmdspanand of incorporating the lessons learned from over a -decade of experience with [P0009R18?] and -libraries of similar design. This paper assumes the reader has read and -is already familiar with [P0009R18?]. +decade of experience with [P0009R18] and libraries of similar +design. This paper assumes the reader has read and is already familiar +with [P0009R18].3.1 Design overview
The analogy to
@@ -638,8 +637,8 @@mdspancan be seen in the declaration of the proposed design formdarray.3 class Container = see-below> class mdarray;
This intentionally parallels the design of
+[P0009R18], which has the following +signature.mdspanin -[P0009R18?], which has -the following signature.template<class ElementType, class Extents, class LayoutPolicy = layout_right, @@ -735,7 +734,7 @@
template<class ElementType, class Extents, class LayoutPolicy, class Container> class mdarray { /* ... */ - + // only in mdarray: using mdspan_type = /* ... */; using const_mdspan_type = /* ... */; @@ -744,10 +743,10 @@operator mdspan() const; template<class OtherAccessorType = default_accessor<element_type>> - auto to_mdspan(const OtherAccessorType& a = + auto to_mdspan(const OtherAccessorType& a = default_accessor<element_type>()) const noexcept; template<class OtherAccessorType = default_accessor<const element_type>> - auto to_mdspan(const OtherAccessorType& a = + auto to_mdspan(const OtherAccessorType& a = default_accessor<const element_type>()) const noexcept; /* ... */ @@ -761,7 +760,7 @@
template<class ElementType, class Extents, class LayoutPolicy, class Container> class mdarray { /* ... */ - + // only in mdarray using container_type = Container; @@ -779,7 +778,7 @@
template<class ElementType, class Extents, class LayoutPolicy, class ContainerPolicy> class mdarray { /* ... */ - + // analogous to mdspan: template<class ET, class Exts, class LP, class CP> constexpr mdarray(const mdarray<ET, Exts, LP, CP>&); @@ -871,10 +870,10 @@of the correct size:
As with
+mdspan, theExtentstemplate parameter tomdarrayshall be a template instantiation of -std::extents, as described in [P0009R18?]. The -concerns addressed by this aspect of the design are exactly the same in -mdarrayandmdspan, so using the same form and -mechanism seems like the right thing to do here.std::extents, as described in [P0009R18]. The concerns addressed by +this aspect of the design are exactly the same inmdarray+andmdspan, so using the same form and mechanism seems like +the right thing to do here.3.4
LayoutPolicydesign reusedWhile not quite as straightforward, the decision to use the same @@ -919,7 +918,7 @@
array
+std::array<int, 9> data = get-underlying-container(a);auto a = mdarray<int, 3, 3>(); -std::array<int, 9> data = get-underlying-container(a);(Whether or not a reference to the underlying container should be obtainable is slightly less clear, though we see no reason why this should not be allowed.) The default for an
mdarraywith @@ -930,7 +929,7 @@vector
+std::vector<int> data = get-underlying-container(a);auto a = mdarray<int, 3, dynamic_extent>(); -std::vector<int> data = get-underlying-container(a);
Moreover, taking a view of a mdarray should yield an
analogous mdspan with consistent semantics (except, of
course, that the latter is nonowning). We provisionally call the method
@@ -1765,7 +1764,7 @@
mdarray is a multidimensional array of elements.
namespace std {
-template<class ElementType, class Extents, class LayoutPolicy, class Container =
+template<class ElementType, class Extents, class LayoutPolicy, class Container =
vector<ElementType>>
class mdarray {
public:
@@ -1811,7 +1810,7 @@ 6 Wo
constexpr mdarray(const mapping_type& m, container_type&& c,);
- template<class OtherElementType, class OtherExtents,
+ template<class OtherElementType, class OtherExtents,
class OtherLayoutPolicy, class OtherContainer>
explicit(see below)
constexpr mdarray(
@@ -1846,12 +1845,12 @@ 6 Wo
constexpr mdarray(const mapping_type& m, container_type&& c, const Alloc& a);
- template<class OtherElementType, class OtherExtents,
- class OtherLayoutPolicy, class OtherContainer,
+ template<class OtherElementType, class OtherExtents,
+ class OtherLayoutPolicy, class OtherContainer,
class Alloc>
explicit(see below)
constexpr mdarray(
- const mdarray<OtherElementType, OtherExtents,
+ const mdarray<OtherElementType, OtherExtents,
OtherLayoutPolicy, OtherContainer>& other, const Alloc& a);
template<class OtherElementType, class OtherExtents,
@@ -1891,8 +1890,8 @@ 6 Wo
constexpr const mapping_type& mapping() const { return map_; }
template<class OtherElementType, class OtherExtents,
- class OtherLayoutType, class OtherAccessorType>
- constexpr operator mdspan () const;
+ class OtherLayoutPolicy, class OtherAccessorType>
+ constexpr operator mdspan<OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessorType> () const;
template<class OtherAccessorType = default_accessor<element_type>>
constexpr mdspan<element_type, extents_type, layout_type, OtherAccessorType>
@@ -2291,7 +2290,7 @@ 6 Wo
template<class OtherElementType, class OtherExtents,
class OtherLayoutPolicy, class OtherContainer>
explicit(see below)
- constexpr mdarray(const mdarray<OtherElementType, OtherExtents,
+ constexpr mdarray(const mdarray<OtherElementType, OtherExtents,
OtherLayoutPolicy, OtherContainer>& other);
24
Mandates:
@@ -2639,7 +2638,7 @@ 6 Wo
template<class OtherElementType, class OtherExtents,
class OtherLayoutPolicy, class OtherContainer, class Alloc>
explicit(see below)
- constexpr mdarray(const mdarray<OtherElementType, OtherExtents,
+ constexpr mdarray(const mdarray<OtherElementType, OtherExtents,
OtherLayoutPolicy, OtherContainer>& other,
const Alloc& a);
25
@@ -2834,16 +2833,17 @@
6 Wo
swap(x.ctr_, y.ctr_);
swap(x.map_, y.map_);
template<class OtherElementType, class OtherExtents,
- class OtherLayoutType, class OtherAccessorType>
+ class OtherLayoutPolicy, class OtherAccessorType>
operator mdspan ();
11
Constraints:
-[11.1]{pnum}
-is_assignable_v<mdspan<element_type, extents_type, layout_type>, mdspan<OtherElementType, OtherExtents, OtherLayoutType, OtherAccessorType>>
-is true.
-[11.2]{pnum} is_same_v<pointer, element_type*>
+
(11.1)
+is_assignable_v<mdspan_type &, mdspan<OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessorType>>
is true.
+(11.2)
+is_same_v<pointer, element_type*> is
+true.
12
Preconditions:
@@ -2857,7 +2857,7 @@
6 Wo
to_mdspan(const OtherAccessorType& a = default_accessor<element_type>());
14
Constraints:
-is_assignable_v<pointer, typename OtherAccessorType::data_handle_type>
+is_assignable_v<pointer &, typename OtherAccessorType::data_handle_type>
is true.
15 Preconditions: @@ -2871,7 +2871,7 @@
17
Constraints:
-is_assignable_v<const_pointer, typename OtherAccessorType::data_handle_type>
+is_assignable_v<const_pointer &, typename OtherAccessorType::data_handle_type>
is true.
18 Preconditions: @@ -2899,6 +2899,12 @@
| Arguments | -Current | -Minimal | -Variadic | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| `default` | -`mda_t()` | -`mda_t()` | -`mda_t()` | +
| Arguments | +Current | +Minimal | +Variadic | ||||
|---|---|---|---|---|---|---|---|
| integrals | -`mda_t(10, 10)` | -`mda_t(10, 10)` | -`mda_t(10, 10)` | +||||
| `default` | +`mda_t()` | +`mda_t()` | +`mda_t()` | ||||
| mapping/extents | -`mda_t(me)` | -`mda_t(me)` | -`mda_t(me)` | +||||
| integrals | +`mda_t(10, 10)` | +`mda_t(10, 10)` | +`mda_t(10, 10)` | ||||
| container + integrals | -`mda_t(extents{10, 10}, c)` | -`mda_t(extents{10, 10}, c)` | -`mda_t(extents{10, 10}, c)` | +||||
| mapping/extents | +`mda_t(me)` | +`mda_t(me)` | +`mda_t(me)` | ||||
| move container + integrals | -`mda_t(extents{10, 10}, move(c))` | -`mda_t(extents{10, 10}, move(c))` | -`mda_t(extents{10, 10}, move(c))` | +||||
| container + integrals | +`mda_t(extents{10, 10}, c)` | +`mda_t(extents{10, 10}, c)` | +`mda_t(extents{10, 10}, c)` | ||||
| container + mapping/extents | -`mda_t(me, c)` | -`mda_t(me, c)` | -`mda_t(me, c)` | +||||
| move container + integrals | +`mda_t(extents{10, 10}, move(c))` | +`mda_t(extents{10, 10}, move(c))` | +`mda_t(extents{10, 10}, move(c))` | ||||
| move container + mapping | -`mda_t(me, move(c))` | -`mda_t(me, move(c))` | -`mda_t(me, move(c))` | +||||
| container + mapping/extents | +`mda_t(me, c)` | +`mda_t(me, c)` | +`mda_t(me, c)` | container + alloc + mapping/extents | -`mda_t(me, c, a)` | -`mda_t(me, c_t(c,a))` | -`mda_t(me, c, a)` | +
| move container + mapping | +`mda_t(me, move(c))` | +`mda_t(me, move(c))` | +`mda_t(me, move(c))` | ||||
| move container + alloc + mapping | -`mda_t(me, move(c), a)` | -`mda_t(me, c_t(move(c),a))` | -`mda_t(me, move(c), a)` | +container + alloc + mapping/extents | +`mda_t(me, c, a)` | +`mda_t(me, c_t(c,a))` | +`mda_t(me, c, a)` |
| extents + value | -`mda_t(e, v)` | -`mda_t(e, c_t(map_t(e).required_span_size(), v))` | -`mda_t(e, v)` | +move container + alloc + mapping | +`mda_t(me, move(c), a)` | +`mda_t(me, c_t(move(c),a))` | +`mda_t(me, move(c), a)` |
| mapping + value | -`mda_t(m, v)` | -`mda_t(m, c_t(m.required_span_size(), v))` | -`mda_t(m, v)` | +||||
| extents + value | +`mda_t(e, v)` | +`mda_t(e, c_t(map_t(e).required_span_size(), v))` | +`mda_t(e, v)` | ||||
| mapping + custom container size | -`mda_t(m, c_t(s))` | -`mda_t(m, c_t(s))` | -`mda_t(m, c_t(s))` or `mda_t(m, s)` for integrals not convertible to `value_type` | +||||
| mapping + value | +`mda_t(m, v)` | +`mda_t(m, c_t(m.required_span_size(), v))` | +`mda_t(m, v)` | ||||
| mapping + custom container size + value | -`mda_t(m, c_t(s, v))` | -`mda_t(m, c_t(s, v))` | -`mda_t(m, s, v)` | +||||
| mapping + custom container size | +`mda_t(m, c_t(s))` | +`mda_t(m, c_t(s))` | +`mda_t(m, c_t(s))` or `mda_t(m, s)` for integrals not convertible to `value_type` | ||||
| extents + value + alloc | -`mda_t(e, v, a)` | -`mda_t(e, c_t(map_t(e).required_span_size(), v, a)))` | -`mda_t(e, v , a)` | +mapping + custom container size + value | +`mda_t(m, c_t(s, v))` | +`mda_t(m, c_t(s, v))` | +`mda_t(m, s, v)` |
| mapping + value + alloc | -`mda_t(m, v, a)` | -`mda_t(m, move(c_t(m.required_span_size(), v, a)))` | -`mda_t(m, v, a)` | +||||
| extents + value + alloc | +`mda_t(e, v, a)` | +`mda_t(e, c_t(map_t(e).required_span_size(), v, a)))` | +`mda_t(e, v , a)` | ||||
| mapping + custom container size + alloc | -`mda_t(m, c_t(s, a))` | -`mda_t(m, c_t(s, a))` | -`mda_t(m, c_t(s, a))` or `mda_t(m, s, a)` for integrals not convertible to `value_type` | +||||
| mapping + value + alloc | +`mda_t(m, v, a)` | +`mda_t(m, move(c_t(m.required_span_size(), v, a)))` | +`mda_t(m, v, a)` | +||||
| mapping + custom container size + alloc | +`mda_t(m, c_t(s, a))` | +`mda_t(m, c_t(s, a))` | +`mda_t(m, c_t(s, a))` or `mda_t(m, s, a)` for integrals not convertible to `value_type` | ||||
| mapping + custom container size + value + alloc | -`mda_t(m, c_t(s, v, a))` | -`mda_t(m, c_t(s, v, a))` | -`mda_t(m, s, v, a)` | +||||
| mapping + custom container size + value + alloc | +`mda_t(m, c_t(s, v, a))` | +`mda_t(m, c_t(s, v, a))` | +`mda_t(m, s, v, a)` | ||||
| iterators | -`mda_t(m, c_t(begin, end))` | -`mda_t(m, c_t(begin, end))` | -`mda_t(m, begin, end)` | +||||
| iterators | +`mda_t(m, c_t(begin, end))` | +`mda_t(m, c_t(begin, end))` | +`mda_t(m, begin, end)` | ||||
| range | -`mda_t(m, c_t(r))` | -`mda_t(m, c_t(r))` | -`mda_t(m, r)` | +||||
| range | +`mda_t(m, c_t(r))` | +`mda_t(m, c_t(r))` | +`mda_t(m, r)` | ||||
| converting mdarray | -`mda_t(mda)` | -`mda_t(mda)` | -`mda_t(mda)` | +||||
| converting mdarray | +`mda_t(mda)` | +`mda_t(mda)` | +`mda_t(mda)` | ||||
| compatible mdspan | -`mda_t(mds)` | -`mda_t(mds)` | -`mda_t(mds)` | +||||
| compatible mdspan | +`mda_t(mds)` | +`mda_t(mds)` | +`mda_t(mds)` | compatible mdspan + allocator | -`mda_t(mds, a)` | -`mda_t(mds, a)` | -`mda_t(mds, a)` | +compatible mdspan + allocator | +`mda_t(mds, a)` | +`mda_t(mds, a)` | +`mda_t(mds, a)` | - -