From 91f7e7f59277b8f9f80ea3522895b0da63e1f7fc Mon Sep 17 00:00:00 2001 From: eiytoq Date: Sat, 10 Jan 2026 14:40:08 +0800 Subject: [PATCH] [libc++][mdspan][NFC] Remove redundant `else` and trailing semicolons (#175024) --- libcxx/include/__mdspan/layout_stride.h | 9 ++++----- libcxx/include/__mdspan/mdspan.h | 25 ++++++++++++------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/libcxx/include/__mdspan/layout_stride.h b/libcxx/include/__mdspan/layout_stride.h index 9d77d71bc359..eb22475756fd 100644 --- a/libcxx/include/__mdspan/layout_stride.h +++ b/libcxx/include/__mdspan/layout_stride.h @@ -272,11 +272,10 @@ public: return [&](index_sequence<_Pos...>) { if ((__extents_.extent(_Pos) * ... * 1) == 0) return static_cast(0); - else - return static_cast( - static_cast(1) + - (((__extents_.extent(_Pos) - static_cast(1)) * __strides_[_Pos]) + ... + - static_cast(0))); + + return static_cast( + static_cast(1) + (((__extents_.extent(_Pos) - static_cast(1)) * __strides_[_Pos]) + + ... + static_cast(0))); }(make_index_sequence<__rank_>()); } } diff --git a/libcxx/include/__mdspan/mdspan.h b/libcxx/include/__mdspan/mdspan.h index 9d3d35cd558a..449baea43f2d 100644 --- a/libcxx/include/__mdspan/mdspan.h +++ b/libcxx/include/__mdspan/mdspan.h @@ -96,9 +96,8 @@ public: } [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr index_type extent(rank_type __r) const noexcept { return __map_.extents().extent(__r); - }; + } -public: //-------------------------------------------------------------------------------- // [mdspan.mdspan.cons], mdspan constructors, assignment, and destructor @@ -242,26 +241,26 @@ public: [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const extents_type& extents() const noexcept { return __map_.extents(); - }; - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const data_handle_type& data_handle() const noexcept { return __ptr_; }; - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const mapping_type& mapping() const noexcept { return __map_; }; - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const accessor_type& accessor() const noexcept { return __acc_; }; + } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const data_handle_type& data_handle() const noexcept { return __ptr_; } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const mapping_type& mapping() const noexcept { return __map_; } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const accessor_type& accessor() const noexcept { return __acc_; } // per LWG-4021 "mdspan::is_always_meow() should be noexcept" [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_unique() noexcept { return mapping_type::is_always_unique(); - }; + } [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_exhaustive() noexcept { return mapping_type::is_always_exhaustive(); - }; + } [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_strided() noexcept { return mapping_type::is_always_strided(); - }; + } - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_unique() const { return __map_.is_unique(); }; - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_exhaustive() const { return __map_.is_exhaustive(); }; - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_strided() const { return __map_.is_strided(); }; - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr index_type stride(rank_type __r) const { return __map_.stride(__r); }; + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_unique() const { return __map_.is_unique(); } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_exhaustive() const { return __map_.is_exhaustive(); } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_strided() const { return __map_.is_strided(); } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr index_type stride(rank_type __r) const { return __map_.stride(__r); } private: _LIBCPP_NO_UNIQUE_ADDRESS data_handle_type __ptr_{};