cpp-proposals-pub icon indicating copy to clipboard operation
cpp-proposals-pub copied to clipboard

P0009: LWG small group review 2022/06/21

Open mhoemmen opened this issue 3 years ago • 5 comments

@crtrott @dalg24 @nliber

  • Adding empty() (see PR #262) will require an LEWG paper or NB comment

  • noexcept additions (see PR #262) are OK (?)

  • extents(const array&) and extents(span) constructors: Rename SizeType (local) template parameter to OtherSizeType, to prevent shadowing class template parameter

  • Change "integral type other than bool" to "a signed or unsigned integer type" (to exclude character types)

  • "is a representable value of type SizeType" -> "is representable as a value of type SizeType (2.2, above [mdspan.extents.helpers] -- also update every instance, e.g., [mdspan.extents.ctor] 2.2) (justification: it's not of type SizeType; it's of some other type)

  • para 9, below extents(const array&): "Preconditions: ..." line is duplicated.

  • para 9.2, below extents(const array&): Could remove the N is zero subcase, as it's redundant.

  • para 11: extents(Integrals...) deduction guide: change size_type to size_t (justification: the class doesn't exist yet, so size_type doesn't exist)

  • [mdspan.layout.reqmts]: for layout mapping operator(), we also need to say that this is less than or equal to size_t max, because size_type could be (e.g.,) __int128 and bigger than size_t.

  • (Note on [mdspan.layout.reqmts]: Use of "Result" vs. "Returns" not consistent, but not bad to leave it.)

  • [mdspan.layoutleft.ctor]: para 3 (actually should be 4): change "Preconditions" to "Precondition" (as there is only one precondition); also fix paragraph numbering (three paragraph 3s in this section)

  • [mdspan.layoutleft.obs]: Para 3 (Preconditions on operator()(Indices... i)): It's just one Precondition, and extents_ should be code font, not italics.

  • [mdspan.layoutright]: generally apply above mdspan.layoutleft.* changes to corresponding paragraphs

  • [mdspan.layoutstride]: In synopsis and mapping(const extents_type&, span<SizeType, rank_>), etc.: use OtherSizeType instead of SizeType for consistency

  • [mdspan.layoutstride]: Change constexpr span<const size_type, rank_> strides() to return array (by value) instead of span, as it was in R16.

  • [mdspan.layoutstride.ctor]: Change SizeType to OtherSizeType (see above synopsis notes).

  • [mdspan.layoutstride.obs]: operator(): This wording forbids implementations from detecting out-of-bounds access for integer-like types, because it just static_casts to size_type. It needs to static_cast in order to support custom (class type) index types. Apply to this and to all layouts: num-cast<size_type>(i) is i if remove_cvref_t<decltype(i)> is an integer-like type, otherwise static_cast<size_type>(i).

  • mdspan(CArray&) deduction guide: add spaces around == to avoid >== being considered as a single token.

  • mdspan(Pointer&) deduction guide: Look again at whether we need lvalue reference; why do we forbid rvalue reference? Do temporary pointers work? Add a test that takes std::move(CArray) or std::move(Pointer).

  • [mdspan.mdspan.members] para 2 and para 6 (operator[]): The same static_cast<size_type>(std::move(indices)) as above; use above num-cast wording. Move "Let P be a parameter pack" up sooner, so you can apply that wording.

  • mdspan::size() needs to return size_t, not size_type (fixed in overview already, not in description).


  • P2604R0: LWG probably won't like this non-diff form.

  • P2604R0: "two uses of contiguous in prose text in notes will be replaced"


  • P2599R1: For additions (not renaming), need to see proper diffs against the paper reviewed in this meeting (R17).

mhoemmen avatar Jun 21 '22 18:06 mhoemmen

Adding empty() (see PR #262) will require an LEWG paper or NB comment

@mhoemmen @nliber I just finished the paper; the draft is at here, pending a paper number.

Really rushed, the wording was copied from R17.

Feel free to make any comments/suggestions!

Original PR now only contains noexcept stuff. Technically if we want to be safe we can add that to paper too; however I personally do think they are okay to merge on their own.

Mick235711 avatar Jun 21 '22 19:06 Mick235711

@Mick235711 you could potentially just inline return size()!=0 instead of adding the description below?

crtrott avatar Jun 21 '22 22:06 crtrott

@crtrott There could be a more optimized implementation of empty(), since it doesn't have to compute the size. As specified an implementation has the freedom to do so.

nliber avatar Jun 21 '22 22:06 nliber

ok sounds good.

crtrott avatar Jun 21 '22 22:06 crtrott

My own notes:

From Mark: make extents_ not math font but italic code font [34160ef53b72]

mdspan.extents

  • SizeType -> OtherSizeType for extens constructor from span/array [2972784b3800cd]

  • par 2.1 - SizeType is a signed or unsigned integer type, and [9d1d7e32678dd1e]

  • par 2.2 - or is representable as a value of type SizeType (check for other instances of this) [3532fe13a539cb65]

    • mdspan.extents.ctor 2.2
    • mdspan.layoutleft.ctor etc.
  • par 9: fix copy paste error [737ec61af5c0fcf]

  • par 11: size_type -> size_t [4dff8c2380b4c03c]

mdspan.layout.reqmts

  • par 8. add smaller then size_t too [3c34587d2f6b]

mdspan.layoutleft.ctor

3: fix all the numbers [f0df8c4f5edd0c6]

mdspan.layoutstride.ctor

  • SizeType -> OtherSizeType [2972784b3800cd]
  • change back strides() -> array<size_type, rank_> [98cf0210f0be4f8c]

mdspan.overview

  • SizeType to OtherSizeType for constructors/operator taking span/array [2972784b3800cd]
  • spaces around == rank_v<CArray>==1 [54ea3cc232aeb]

mdspan.oberservers

  • repeat and fix precondition for indicies from mappings [54ea3cc232aeb] num-cast<size_type>(i) is i if remve_cvref_t<decltype(i)> is integer-like type, otehrwise static_cast<size_type>(i)

crtrott avatar Jun 21 '22 23:06 crtrott