@@ -87,12 +87,14 @@ class mdspan {
8787 using data_handle_type = typename accessor_type::data_handle_type;
8888 using reference = typename accessor_type::reference;
8989
90- _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank () noexcept { return extents_type::rank (); }
91- _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank_dynamic () noexcept { return extents_type::rank_dynamic (); }
92- _LIBCPP_HIDE_FROM_ABI static constexpr size_t static_extent (rank_type __r) noexcept {
90+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank () noexcept { return extents_type::rank (); }
91+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank_dynamic () noexcept {
92+ return extents_type::rank_dynamic ();
93+ }
94+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr size_t static_extent (rank_type __r) noexcept {
9395 return extents_type::static_extent (__r);
9496 }
95- _LIBCPP_HIDE_FROM_ABI constexpr index_type extent (rank_type __r) const noexcept {
97+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr index_type extent (rank_type __r) const noexcept {
9698 return __map_.extents ().extent (__r);
9799 };
98100
@@ -185,7 +187,7 @@ class mdspan {
185187 requires ((is_convertible_v<_OtherIndexTypes, index_type> && ...) &&
186188 (is_nothrow_constructible_v<index_type, _OtherIndexTypes> && ...) &&
187189 (sizeof ...(_OtherIndexTypes) == rank()))
188- _LIBCPP_HIDE_FROM_ABI constexpr reference operator [](_OtherIndexTypes... __indices) const {
190+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference operator [](_OtherIndexTypes... __indices) const {
189191 // Note the standard layouts would also check this, but user provided ones may not, so we
190192 // check the precondition here
191193 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (__mdspan_detail::__is_multidimensional_index_in (extents (), __indices...),
@@ -196,7 +198,8 @@ class mdspan {
196198 template <class _OtherIndexType >
197199 requires (is_convertible_v<const _OtherIndexType&, index_type> &&
198200 is_nothrow_constructible_v<index_type, const _OtherIndexType&>)
199- _LIBCPP_HIDE_FROM_ABI constexpr reference operator [](const array< _OtherIndexType, rank()>& __indices) const {
201+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference
202+ operator [](const array< _OtherIndexType, rank()>& __indices) const {
200203 return __acc_.access (__ptr_, [&]<size_t ... _Idxs>(index_sequence<_Idxs...>) {
201204 return __map_ (__indices[_Idxs]...);
202205 }(make_index_sequence<rank ()>()));
@@ -205,7 +208,7 @@ class mdspan {
205208 template <class _OtherIndexType >
206209 requires (is_convertible_v<const _OtherIndexType&, index_type> &&
207210 is_nothrow_constructible_v<index_type, const _OtherIndexType&>)
208- _LIBCPP_HIDE_FROM_ABI constexpr reference operator [](span<_OtherIndexType, rank()> __indices) const {
211+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference operator [](span<_OtherIndexType, rank()> __indices) const {
209212 return __acc_.access (__ptr_, [&]<size_t ... _Idxs>(index_sequence<_Idxs...>) {
210213 return __map_ (__indices[_Idxs]...);
211214 }(make_index_sequence<rank ()>()));
@@ -237,24 +240,28 @@ class mdspan {
237240 swap (__x.__acc_ , __y.__acc_ );
238241 }
239242
240- _LIBCPP_HIDE_FROM_ABI constexpr const extents_type& extents () const noexcept { return __map_.extents (); };
241- _LIBCPP_HIDE_FROM_ABI constexpr const data_handle_type& data_handle () const noexcept { return __ptr_; };
242- _LIBCPP_HIDE_FROM_ABI constexpr const mapping_type& mapping () const noexcept { return __map_; };
243- _LIBCPP_HIDE_FROM_ABI constexpr const accessor_type& accessor () const noexcept { return __acc_; };
243+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const extents_type& extents () const noexcept {
244+ return __map_.extents ();
245+ };
246+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const data_handle_type& data_handle () const noexcept { return __ptr_; };
247+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const mapping_type& mapping () const noexcept { return __map_; };
248+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const accessor_type& accessor () const noexcept { return __acc_; };
244249
245250 // per LWG-4021 "mdspan::is_always_meow() should be noexcept"
246- _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_unique () noexcept { return mapping_type::is_always_unique (); };
247- _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_exhaustive () noexcept {
251+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_unique () noexcept {
252+ return mapping_type::is_always_unique ();
253+ };
254+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_exhaustive () noexcept {
248255 return mapping_type::is_always_exhaustive ();
249256 };
250- _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_strided () noexcept {
257+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_strided () noexcept {
251258 return mapping_type::is_always_strided ();
252259 };
253260
254- _LIBCPP_HIDE_FROM_ABI constexpr bool is_unique () const { return __map_.is_unique (); };
255- _LIBCPP_HIDE_FROM_ABI constexpr bool is_exhaustive () const { return __map_.is_exhaustive (); };
256- _LIBCPP_HIDE_FROM_ABI constexpr bool is_strided () const { return __map_.is_strided (); };
257- _LIBCPP_HIDE_FROM_ABI constexpr index_type stride (rank_type __r) const { return __map_.stride (__r); };
261+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_unique () const { return __map_.is_unique (); };
262+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_exhaustive () const { return __map_.is_exhaustive (); };
263+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_strided () const { return __map_.is_strided (); };
264+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr index_type stride (rank_type __r) const { return __map_.stride (__r); };
258265
259266private:
260267 _LIBCPP_NO_UNIQUE_ADDRESS data_handle_type __ptr_{};
0 commit comments