From 3923312fbbc7c732844892ff2e1324aed463aa11 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Tue, 25 Feb 2025 15:04:28 -0700 Subject: [PATCH] :arrow_up: Add support for clang-19 --- .github/workflows/unit_tests.yml | 19 +++++-- README.md | 2 +- include/stdx/atomic_bitset.hpp | 25 ++++---- include/stdx/bit.hpp | 76 ++++++++++++------------- include/stdx/bitset.hpp | 10 ++-- include/stdx/byterator.hpp | 34 +++++------ include/stdx/ct_format.hpp | 4 +- include/stdx/ct_string.hpp | 6 +- include/stdx/cx_map.hpp | 12 ++-- include/stdx/cx_multimap.hpp | 12 ++-- include/stdx/cx_queue.hpp | 8 +-- include/stdx/cx_set.hpp | 4 +- include/stdx/cx_vector.hpp | 38 +++++++------ include/stdx/intrusive_forward_list.hpp | 12 ++-- include/stdx/intrusive_list.hpp | 12 ++-- include/stdx/numeric.hpp | 4 +- include/stdx/optional.hpp | 28 +++++---- include/stdx/rollover.hpp | 29 ++++++---- include/stdx/span.hpp | 20 +++---- include/stdx/tuple.hpp | 35 ++++++------ include/stdx/tuple_algorithms.hpp | 12 ++-- include/stdx/type_traits.hpp | 4 +- include/stdx/udls.hpp | 24 ++++---- test/detail/tuple_types.hpp | 4 +- test/optional.cpp | 8 +-- 25 files changed, 235 insertions(+), 207 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index e375007..6c08d9d 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -13,7 +13,7 @@ env: DEBIAN_FRONTEND: noninteractive CMAKE_GENERATOR: Ninja DEFAULT_CXX_STANDARD: 20 - DEFAULT_LLVM_VERSION: 18 + DEFAULT_LLVM_VERSION: 19 DEFAULT_GCC_VERSION: 13 MULL_LLVM_VERSION: 17 HYPOTHESIS_PROFILE: default @@ -29,7 +29,7 @@ jobs: fail-fast: false matrix: compiler: [clang, gcc] - version: [12, 13, 16, 17, 18] + version: [12, 13, 16, 17, 18, 19] cxx_standard: [17, 20] stdlib: [libstdc++, libc++] build_type: [Debug] @@ -38,6 +38,15 @@ jobs: cc: "clang" cxx: "clang++" cxx_flags: "-stdlib=libstdc++" + - version: 19 + compiler: clang + install: sudo apt update && sudo apt install -y clang-19 + toolchain_root: "/usr/lib/llvm-19" + - version: 19 + compiler: clang + stdlib: libc++ + install: sudo apt update && sudo apt install -y clang-19 libc++-19-dev libc++abi-19-dev + cxx_flags: "-stdlib=libc++" - version: 18 compiler: clang install: sudo apt update && sudo apt install -y clang-18 @@ -80,6 +89,8 @@ jobs: cxx: "g++-12" cxx_flags: "" exclude: + - compiler: gcc + version: 19 - compiler: gcc version: 18 - compiler: gcc @@ -293,8 +304,8 @@ jobs: - compiler: clang cc: "clang" cxx: "clang++" - install: sudo apt update && sudo apt install -y clang-18 - toolchain_root: "/usr/lib/llvm-18" + install: sudo apt update && sudo apt install -y clang-19 + toolchain_root: "/usr/lib/llvm-19" - compiler: gcc cc: "gcc-13" cxx: "g++-13" diff --git a/README.md b/README.md index 72e9087..9a85bcb 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Some of the extras are available only with C++20 or later. *stdx* supports: -- clang 14 through 18 +- clang 14 through 19 - gcc 12 through 13 See the [full documentation](https://intel.github.io/cpp-std-extensions/). diff --git a/include/stdx/atomic_bitset.hpp b/include/stdx/atomic_bitset.hpp index 3cf9941..4cf5ccc 100644 --- a/include/stdx/atomic_bitset.hpp +++ b/include/stdx/atomic_bitset.hpp @@ -153,8 +153,8 @@ class atomic_bitset { return set(lsb, static_cast(l + length - 1), value, order); } - auto set(std::memory_order order = std::memory_order_seq_cst) - LIFETIMEBOUND -> atomic_bitset & { + auto set(std::memory_order order = std::memory_order_seq_cst) LIFETIMEBOUND + -> atomic_bitset & { atomic::store(storage, mask, order); return *this; } @@ -167,32 +167,33 @@ class atomic_bitset { storage, static_cast(~(bit << pos)), order)}; } - auto - reset(lsb_t lsb, msb_t msb, - std::memory_order order = std::memory_order_seq_cst) -> bitset_t { + auto reset(lsb_t lsb, msb_t msb, + std::memory_order order = std::memory_order_seq_cst) + -> bitset_t { auto const l = to_underlying(lsb); auto const m = to_underlying(msb); auto const shifted_value = bit_mask(m, l); return bitset_t{atomic::fetch_and(storage, ~shifted_value, order)}; } - auto - reset(lsb_t lsb, length_t len, - std::memory_order order = std::memory_order_seq_cst) -> bitset_t { + auto reset(lsb_t lsb, length_t len, + std::memory_order order = std::memory_order_seq_cst) + -> bitset_t { auto const l = to_underlying(lsb); auto const length = to_underlying(len); return reset(lsb, static_cast(l + length - 1), order); } - auto reset(std::memory_order order = std::memory_order_seq_cst) - LIFETIMEBOUND -> atomic_bitset & { + auto + reset(std::memory_order order = std::memory_order_seq_cst) LIFETIMEBOUND + -> atomic_bitset & { atomic::store(storage, elem_t{}, order); return *this; } template - auto flip(T idx, - std::memory_order order = std::memory_order_seq_cst) -> bitset_t { + auto flip(T idx, std::memory_order order = std::memory_order_seq_cst) + -> bitset_t { auto const pos = static_cast(to_underlying(idx)); return bitset_t{ atomic::fetch_xor(storage, static_cast(bit << pos), order)}; diff --git a/include/stdx/bit.hpp b/include/stdx/bit.hpp index 2eadb95..9e8af51 100644 --- a/include/stdx/bit.hpp +++ b/include/stdx/bit.hpp @@ -47,8 +47,8 @@ using std::bit_cast; #if __cpp_lib_byteswap < 202110L template -[[nodiscard]] constexpr auto -byteswap(T x) noexcept -> std::enable_if_t, T> { +[[nodiscard]] constexpr auto byteswap(T x) noexcept + -> std::enable_if_t, T> { if constexpr (sizeof(T) == sizeof(std::uint16_t)) { return __builtin_bswap16(x); } else if constexpr (sizeof(T) == sizeof(std::uint32_t)) { @@ -67,8 +67,8 @@ using std::byteswap; #if __cpp_lib_bitops < 201907L template -[[nodiscard]] constexpr auto -countl_zero(T x) noexcept -> std::enable_if_t, int> { +[[nodiscard]] constexpr auto countl_zero(T x) noexcept + -> std::enable_if_t, int> { if (x == 0) { return std::numeric_limits::digits; } @@ -88,8 +88,8 @@ countl_zero(T x) noexcept -> std::enable_if_t, int> { } template -[[nodiscard]] constexpr auto -countr_zero(T x) noexcept -> std::enable_if_t, int> { +[[nodiscard]] constexpr auto countr_zero(T x) noexcept + -> std::enable_if_t, int> { if (x == 0) { return std::numeric_limits::digits; } @@ -104,20 +104,20 @@ countr_zero(T x) noexcept -> std::enable_if_t, int> { } template -[[nodiscard]] constexpr auto -countl_one(T x) noexcept -> std::enable_if_t, int> { +[[nodiscard]] constexpr auto countl_one(T x) noexcept + -> std::enable_if_t, int> { return countl_zero(T(~x)); } template -[[nodiscard]] constexpr auto -countr_one(T x) noexcept -> std::enable_if_t, int> { +[[nodiscard]] constexpr auto countr_one(T x) noexcept + -> std::enable_if_t, int> { return countr_zero(T(~x)); } template -[[nodiscard]] constexpr auto -popcount(T x) noexcept -> std::enable_if_t, int> { +[[nodiscard]] constexpr auto popcount(T x) noexcept + -> std::enable_if_t, int> { if constexpr (sizeof(T) <= sizeof(unsigned int)) { return __builtin_popcount(x); } else if constexpr (sizeof(T) <= @@ -130,8 +130,8 @@ popcount(T x) noexcept -> std::enable_if_t, int> { namespace detail { template -[[nodiscard]] constexpr auto -rotl(T x, T s) noexcept -> std::enable_if_t, T> { +[[nodiscard]] constexpr auto rotl(T x, T s) noexcept + -> std::enable_if_t, T> { #ifdef __clang__ if constexpr (sizeof(T) == sizeof(std::uint8_t)) { return __builtin_rotateleft8(x, s); @@ -148,8 +148,8 @@ rotl(T x, T s) noexcept -> std::enable_if_t, T> { #endif } template -[[nodiscard]] constexpr auto -rotr(T x, T s) noexcept -> std::enable_if_t, T> { +[[nodiscard]] constexpr auto rotr(T x, T s) noexcept + -> std::enable_if_t, T> { #ifdef __clang__ if constexpr (sizeof(T) == sizeof(std::uint8_t)) { return __builtin_rotateright8(x, s); @@ -168,8 +168,8 @@ rotr(T x, T s) noexcept -> std::enable_if_t, T> { } // namespace detail template -[[nodiscard]] constexpr auto -rotl(T x, int s) noexcept -> std::enable_if_t, T> { +[[nodiscard]] constexpr auto rotl(T x, int s) noexcept + -> std::enable_if_t, T> { if (s == 0) { return x; } @@ -180,8 +180,8 @@ rotl(T x, int s) noexcept -> std::enable_if_t, T> { } template -[[nodiscard]] constexpr auto -rotr(T x, int s) noexcept -> std::enable_if_t, T> { +[[nodiscard]] constexpr auto rotr(T x, int s) noexcept + -> std::enable_if_t, T> { if (s == 0) { return x; } @@ -204,20 +204,20 @@ using std::rotr; #if __cpp_lib_int_pow2 < 202002L template -[[nodiscard]] constexpr auto -has_single_bit(T x) noexcept -> std::enable_if_t, bool> { +[[nodiscard]] constexpr auto has_single_bit(T x) noexcept + -> std::enable_if_t, bool> { return x and not(x & (x - 1)); } template -[[nodiscard]] constexpr auto -bit_width(T x) noexcept -> std::enable_if_t, int> { +[[nodiscard]] constexpr auto bit_width(T x) noexcept + -> std::enable_if_t, int> { return std::numeric_limits::digits - countl_zero(x); } template -[[nodiscard]] constexpr auto -bit_ceil(T x) noexcept -> std::enable_if_t, T> { +[[nodiscard]] constexpr auto bit_ceil(T x) noexcept + -> std::enable_if_t, T> { if (x <= 1U) { return 1U; } @@ -225,8 +225,8 @@ bit_ceil(T x) noexcept -> std::enable_if_t, T> { } template -[[nodiscard]] constexpr auto -bit_floor(T x) noexcept -> std::enable_if_t, T> { +[[nodiscard]] constexpr auto bit_floor(T x) noexcept + -> std::enable_if_t, T> { if (x == 0) { return x; } @@ -240,8 +240,8 @@ using std::has_single_bit; #endif template -[[nodiscard]] constexpr auto -to_le(T x) noexcept -> std::enable_if_t, T> { +[[nodiscard]] constexpr auto to_le(T x) noexcept + -> std::enable_if_t, T> { if constexpr (stdx::endian::native == stdx::endian::big) { return byteswap(x); } else { @@ -250,8 +250,8 @@ to_le(T x) noexcept -> std::enable_if_t, T> { } template -[[nodiscard]] constexpr auto -to_be(T x) noexcept -> std::enable_if_t, T> { +[[nodiscard]] constexpr auto to_be(T x) noexcept + -> std::enable_if_t, T> { if constexpr (stdx::endian::native == stdx::endian::little) { return byteswap(x); } else { @@ -260,8 +260,8 @@ to_be(T x) noexcept -> std::enable_if_t, T> { } template -[[nodiscard]] constexpr auto -from_le(T x) noexcept -> std::enable_if_t, T> { +[[nodiscard]] constexpr auto from_le(T x) noexcept + -> std::enable_if_t, T> { if constexpr (stdx::endian::native == stdx::endian::big) { return byteswap(x); } else { @@ -270,8 +270,8 @@ from_le(T x) noexcept -> std::enable_if_t, T> { } template -[[nodiscard]] constexpr auto -from_be(T x) noexcept -> std::enable_if_t, T> { +[[nodiscard]] constexpr auto from_be(T x) noexcept + -> std::enable_if_t, T> { if constexpr (stdx::endian::native == stdx::endian::little) { return byteswap(x); } else { @@ -341,8 +341,8 @@ template constexpr auto bit_unpack(From arg) { namespace detail { template -constexpr auto -mask_bits() -> std::enable_if_t::digits, T> { +constexpr auto mask_bits() + -> std::enable_if_t::digits, T> { if constexpr (Bit == std::numeric_limits::digits) { return std::numeric_limits::max(); } else { diff --git a/include/stdx/bitset.hpp b/include/stdx/bitset.hpp index 9600dc2..8115f98 100644 --- a/include/stdx/bitset.hpp +++ b/include/stdx/bitset.hpp @@ -243,8 +243,8 @@ class bitset { return *this; } - constexpr auto set(lsb_t lsb, msb_t msb, - bool value = true) LIFETIMEBOUND -> bitset & { + constexpr auto set(lsb_t lsb, msb_t msb, bool value = true) LIFETIMEBOUND + -> bitset & { auto const l = to_underlying(lsb); auto const m = to_underlying(msb); auto [l_index, l_offset] = indices(l); @@ -272,8 +272,8 @@ class bitset { return *this; } - constexpr auto set(lsb_t lsb, length_t len, - bool value = true) LIFETIMEBOUND -> bitset & { + constexpr auto set(lsb_t lsb, length_t len, bool value = true) LIFETIMEBOUND + -> bitset & { auto const l = to_underlying(lsb); auto const length = to_underlying(len); return set(lsb, static_cast(l + length - 1), value); @@ -398,7 +398,7 @@ class bitset { constexpr auto operator<<=(std::size_t pos) LIFETIMEBOUND->bitset & { auto dst = storage_size - 1; - auto const start = dst - pos / storage_elem_size; + auto const start = dst - (pos / storage_elem_size); pos %= storage_elem_size; if (pos == 0) { diff --git a/include/stdx/byterator.hpp b/include/stdx/byterator.hpp index 06f7782..01c9901 100644 --- a/include/stdx/byterator.hpp +++ b/include/stdx/byterator.hpp @@ -42,8 +42,8 @@ template class byterator { template , T>, int> = 0> - [[nodiscard]] constexpr friend auto operator==(byterator const &x, - It y) -> bool { + [[nodiscard]] constexpr friend auto operator==(byterator const &x, It y) + -> bool { return static_cast(x.ptr) == static_cast(stdx::to_address(y)); } @@ -60,18 +60,18 @@ template class byterator { } template - [[nodiscard]] constexpr friend auto operator==(It y, - byterator const &x) -> bool { + [[nodiscard]] constexpr friend auto operator==(It y, byterator const &x) + -> bool { return x == y; } template - [[nodiscard]] constexpr friend auto operator!=(byterator const &x, - It y) -> bool { + [[nodiscard]] constexpr friend auto operator!=(byterator const &x, It y) + -> bool { return not(x == y); } template - [[nodiscard]] constexpr friend auto operator!=(It y, - byterator const &x) -> bool { + [[nodiscard]] constexpr friend auto operator!=(It y, byterator const &x) + -> bool { return not(x == y); } @@ -135,8 +135,9 @@ template class byterator { return *this; } - [[nodiscard]] friend constexpr auto - operator+(byterator i, difference_type d) -> byterator { + [[nodiscard]] friend constexpr auto operator+(byterator i, + difference_type d) + -> byterator { i += d; return i; } @@ -145,21 +146,22 @@ template class byterator { i += d; return i; } - [[nodiscard]] friend constexpr auto - operator-(byterator i, difference_type d) -> byterator { + [[nodiscard]] friend constexpr auto operator-(byterator i, + difference_type d) + -> byterator { i -= d; return i; } - [[nodiscard]] friend constexpr auto - operator-(byterator x, byterator y) -> difference_type { + [[nodiscard]] friend constexpr auto operator-(byterator x, byterator y) + -> difference_type { return x.ptr - y.ptr; } [[nodiscard]] constexpr auto operator[](difference_type n) -> byte_t & { return ptr[n]; } - [[nodiscard]] constexpr auto - operator[](difference_type n) const -> byte_t const & { + [[nodiscard]] constexpr auto operator[](difference_type n) const + -> byte_t const & { return ptr[n]; } diff --git a/include/stdx/ct_format.hpp b/include/stdx/ct_format.hpp index 9524f0a..a717e02 100644 --- a/include/stdx/ct_format.hpp +++ b/include/stdx/ct_format.hpp @@ -26,8 +26,8 @@ template constexpr auto format_as(stdx::ct_string const &s) { } template struct format_result { - CONSTEVAL static auto - ct_string_convertible() -> std::bool_constant; + CONSTEVAL static auto ct_string_convertible() + -> std::bool_constant; [[no_unique_address]] Str str; [[no_unique_address]] Args args{}; diff --git a/include/stdx/ct_string.hpp b/include/stdx/ct_string.hpp index 79dc1f9..1b72874 100644 --- a/include/stdx/ct_string.hpp +++ b/include/stdx/ct_string.hpp @@ -121,9 +121,9 @@ template [[nodiscard]] consteval auto split() { } template -[[nodiscard]] constexpr auto -operator+(ct_string const &lhs, - ct_string const &rhs) -> ct_string { +[[nodiscard]] constexpr auto operator+(ct_string const &lhs, + ct_string const &rhs) + -> ct_string { ct_string ret{}; for (auto i = std::size_t{}; i < lhs.size(); ++i) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-*) diff --git a/include/stdx/cx_map.hpp b/include/stdx/cx_map.hpp index 09c43d7..6865cad 100644 --- a/include/stdx/cx_map.hpp +++ b/include/stdx/cx_map.hpp @@ -50,8 +50,8 @@ template class cx_map { [[nodiscard]] constexpr auto begin() const LIFETIMEBOUND -> const_iterator { return std::data(storage); } - [[nodiscard]] constexpr auto - cbegin() const LIFETIMEBOUND -> const_iterator { + [[nodiscard]] constexpr auto cbegin() const LIFETIMEBOUND + -> const_iterator { return std::data(storage); } @@ -83,8 +83,8 @@ template class cx_map { return storage[--current_size]; } - [[nodiscard]] constexpr auto - get(key_type const &key) LIFETIMEBOUND -> mapped_type & { + [[nodiscard]] constexpr auto get(key_type const &key) LIFETIMEBOUND + -> mapped_type & { for (auto &[k, v] : *this) { if (k == key) { return v; @@ -92,8 +92,8 @@ template class cx_map { } unreachable(); } - [[nodiscard]] constexpr auto - get(key_type const &key) const LIFETIMEBOUND -> mapped_type const & { + [[nodiscard]] constexpr auto get(key_type const &key) const LIFETIMEBOUND + -> mapped_type const & { for (auto const &[k, v] : *this) { if (k == key) { return v; diff --git a/include/stdx/cx_multimap.hpp b/include/stdx/cx_multimap.hpp index a5ca673..86ba742 100644 --- a/include/stdx/cx_multimap.hpp +++ b/include/stdx/cx_multimap.hpp @@ -31,8 +31,8 @@ class cx_multimap { [[nodiscard]] constexpr auto begin() const LIFETIMEBOUND -> const_iterator { return std::begin(storage); } - [[nodiscard]] constexpr auto - cbegin() const LIFETIMEBOUND -> const_iterator { + [[nodiscard]] constexpr auto cbegin() const LIFETIMEBOUND + -> const_iterator { return std::cbegin(storage); } @@ -82,12 +82,12 @@ class cx_multimap { return 0; } - [[nodiscard]] constexpr auto - get(key_type const &key) LIFETIMEBOUND -> set_t & { + [[nodiscard]] constexpr auto get(key_type const &key) LIFETIMEBOUND + -> set_t & { return storage.get(key); } - [[nodiscard]] constexpr auto - get(key_type const &key) const LIFETIMEBOUND -> set_t const & { + [[nodiscard]] constexpr auto get(key_type const &key) const LIFETIMEBOUND + -> set_t const & { return storage.get(key); } diff --git a/include/stdx/cx_queue.hpp b/include/stdx/cx_queue.hpp index e9f777b..3401836 100644 --- a/include/stdx/cx_queue.hpp +++ b/include/stdx/cx_queue.hpp @@ -66,8 +66,8 @@ class cx_queue { OverflowPolicy::check_pop(current_size); return storage[pop_index]; } - [[nodiscard]] constexpr auto front() const - & LIFETIMEBOUND -> const_reference { + [[nodiscard]] constexpr auto front() const & LIFETIMEBOUND + -> const_reference { OverflowPolicy::check_pop(current_size); return storage[pop_index]; } @@ -75,8 +75,8 @@ class cx_queue { OverflowPolicy::check_pop(current_size); return storage[push_index]; } - [[nodiscard]] constexpr auto back() const - & LIFETIMEBOUND -> const_reference { + [[nodiscard]] constexpr auto back() const & LIFETIMEBOUND + -> const_reference { OverflowPolicy::check_pop(current_size); return storage[push_index]; } diff --git a/include/stdx/cx_set.hpp b/include/stdx/cx_set.hpp index 6e3ceee..8b0effc 100644 --- a/include/stdx/cx_set.hpp +++ b/include/stdx/cx_set.hpp @@ -38,8 +38,8 @@ template class cx_set { [[nodiscard]] constexpr auto begin() const LIFETIMEBOUND -> const_iterator { return std::data(storage); } - [[nodiscard]] constexpr auto - cbegin() const LIFETIMEBOUND -> const_iterator { + [[nodiscard]] constexpr auto cbegin() const LIFETIMEBOUND + -> const_iterator { return std::data(storage); } diff --git a/include/stdx/cx_vector.hpp b/include/stdx/cx_vector.hpp index befb8d9..550c947 100644 --- a/include/stdx/cx_vector.hpp +++ b/include/stdx/cx_vector.hpp @@ -45,8 +45,8 @@ template class cx_vector { [[nodiscard]] constexpr auto begin() const LIFETIMEBOUND -> const_iterator { return std::data(storage); } - [[nodiscard]] constexpr auto - cbegin() const LIFETIMEBOUND -> const_iterator { + [[nodiscard]] constexpr auto cbegin() const LIFETIMEBOUND + -> const_iterator { return std::data(storage); } @@ -63,32 +63,32 @@ template class cx_vector { [[nodiscard]] constexpr auto rbegin() LIFETIMEBOUND -> reverse_iterator { return end(); } - [[nodiscard]] constexpr auto - rbegin() const LIFETIMEBOUND -> const_reverse_iterator { + [[nodiscard]] constexpr auto rbegin() const LIFETIMEBOUND + -> const_reverse_iterator { return end(); } - [[nodiscard]] constexpr auto - crbegin() const LIFETIMEBOUND -> const_reverse_iterator { + [[nodiscard]] constexpr auto crbegin() const LIFETIMEBOUND + -> const_reverse_iterator { return cend(); } [[nodiscard]] constexpr auto rend() LIFETIMEBOUND -> reverse_iterator { return begin(); } - [[nodiscard]] constexpr auto - rend() const LIFETIMEBOUND -> const_reverse_iterator { + [[nodiscard]] constexpr auto rend() const LIFETIMEBOUND + -> const_reverse_iterator { return begin(); } - [[nodiscard]] constexpr auto - crend() const LIFETIMEBOUND -> const_reverse_iterator { + [[nodiscard]] constexpr auto crend() const LIFETIMEBOUND + -> const_reverse_iterator { return cbegin(); } [[nodiscard]] constexpr auto front() LIFETIMEBOUND -> reference { return storage[0]; } - [[nodiscard]] constexpr auto - front() const LIFETIMEBOUND -> const_reference { + [[nodiscard]] constexpr auto front() const LIFETIMEBOUND + -> const_reference { return storage[0]; } [[nodiscard]] constexpr auto back() LIFETIMEBOUND -> reference { @@ -130,8 +130,8 @@ template class cx_vector { constexpr auto clear() -> void { current_size = 0; } - constexpr auto - push_back(value_type const &value) LIFETIMEBOUND -> reference { + constexpr auto push_back(value_type const &value) LIFETIMEBOUND + -> reference { return storage[current_size++] = value; } constexpr auto push_back(value_type &&value) LIFETIMEBOUND -> reference { @@ -149,8 +149,9 @@ template class cx_vector { std::forward(f)(std::data(v.storage), std::size(v.storage)); } - [[nodiscard]] friend constexpr auto - operator==(cx_vector const &lhs, cx_vector const &rhs) -> bool { + [[nodiscard]] friend constexpr auto operator==(cx_vector const &lhs, + cx_vector const &rhs) + -> bool { if (lhs.size() != rhs.size()) { return false; } @@ -163,8 +164,9 @@ template class cx_vector { } #if __cpp_impl_three_way_comparison < 201907L - [[nodiscard]] friend constexpr auto - operator!=(cx_vector const &lhs, cx_vector const &rhs) -> bool { + [[nodiscard]] friend constexpr auto operator!=(cx_vector const &lhs, + cx_vector const &rhs) + -> bool { return not(lhs == rhs); } #endif diff --git a/include/stdx/intrusive_forward_list.hpp b/include/stdx/intrusive_forward_list.hpp index dcd01f4..c231fc9 100644 --- a/include/stdx/intrusive_forward_list.hpp +++ b/include/stdx/intrusive_forward_list.hpp @@ -45,17 +45,17 @@ class intrusive_forward_list { pointer node{}; #if __cpp_impl_three_way_comparison < 201907L - friend constexpr auto operator==(iterator_t lhs, - iterator_t rhs) -> bool { + friend constexpr auto operator==(iterator_t lhs, iterator_t rhs) + -> bool { return lhs.node == rhs.node; } - friend constexpr auto operator!=(iterator_t lhs, - iterator_t rhs) -> bool { + friend constexpr auto operator!=(iterator_t lhs, iterator_t rhs) + -> bool { return not(lhs == rhs); } #else - friend constexpr auto operator==(iterator_t, - iterator_t) -> bool = default; + friend constexpr auto operator==(iterator_t, iterator_t) + -> bool = default; #endif }; diff --git a/include/stdx/intrusive_list.hpp b/include/stdx/intrusive_list.hpp index 4351be3..3cee6c1 100644 --- a/include/stdx/intrusive_list.hpp +++ b/include/stdx/intrusive_list.hpp @@ -46,17 +46,17 @@ class intrusive_list { pointer node{}; #if __cpp_impl_three_way_comparison < 201907L - friend constexpr auto operator==(iterator_t lhs, - iterator_t rhs) -> bool { + friend constexpr auto operator==(iterator_t lhs, iterator_t rhs) + -> bool { return lhs.node == rhs.node; } - friend constexpr auto operator!=(iterator_t lhs, - iterator_t rhs) -> bool { + friend constexpr auto operator!=(iterator_t lhs, iterator_t rhs) + -> bool { return not(lhs == rhs); } #else - friend constexpr auto operator==(iterator_t, - iterator_t) -> bool = default; + friend constexpr auto operator==(iterator_t, iterator_t) + -> bool = default; #endif }; diff --git a/include/stdx/numeric.hpp b/include/stdx/numeric.hpp index a8dcc05..1fe3db2 100644 --- a/include/stdx/numeric.hpp +++ b/include/stdx/numeric.hpp @@ -17,8 +17,8 @@ inline namespace v1 { template CONSTEXPR_INVOKE auto transform_reduce(InputIt first, InputIt last, T init, - ROp rop, TOp top, - InputItN... first_n) -> T { + ROp rop, TOp top, InputItN... first_n) + -> T { while (first != last) { init = std::invoke(rop, std::move(init), std::invoke(top, *first, *first_n...)); diff --git a/include/stdx/optional.hpp b/include/stdx/optional.hpp index 39b33f7..29912ca 100644 --- a/include/stdx/optional.hpp +++ b/include/stdx/optional.hpp @@ -91,15 +91,15 @@ template > class optional { [[nodiscard]] constexpr auto value() & LIFETIMEBOUND -> value_type & { return val; } - [[nodiscard]] constexpr auto value() const - & LIFETIMEBOUND -> value_type const & { + [[nodiscard]] constexpr auto value() const & LIFETIMEBOUND + -> value_type const & { return val; } [[nodiscard]] constexpr auto value() && LIFETIMEBOUND -> value_type && { return std::move(val); } - [[nodiscard]] constexpr auto value() const - && LIFETIMEBOUND -> value_type const && { + [[nodiscard]] constexpr auto value() const && LIFETIMEBOUND + -> value_type const && { return std::move(val); } @@ -206,14 +206,16 @@ template > class optional { } private: - [[nodiscard]] friend constexpr auto - operator==(optional const &lhs, optional const &rhs) -> bool { + [[nodiscard]] friend constexpr auto operator==(optional const &lhs, + optional const &rhs) + -> bool { return lhs.val == rhs.val; } #if __cpp_impl_three_way_comparison < 201907L - [[nodiscard]] friend constexpr auto - operator!=(optional const &lhs, optional const &rhs) -> bool { + [[nodiscard]] friend constexpr auto operator!=(optional const &lhs, + optional const &rhs) + -> bool { return not(lhs == rhs); } #endif @@ -224,16 +226,18 @@ template > class optional { ? lhs.val < rhs.val : not lhs.has_value() and rhs.has_value(); } - [[nodiscard]] friend constexpr auto - operator<=(optional const &lhs, optional const &rhs) -> bool { + [[nodiscard]] friend constexpr auto operator<=(optional const &lhs, + optional const &rhs) + -> bool { return not(rhs < lhs); } [[nodiscard]] friend constexpr auto operator>(optional const &lhs, optional const &rhs) -> bool { return rhs < lhs; } - [[nodiscard]] friend constexpr auto - operator>=(optional const &lhs, optional const &rhs) -> bool { + [[nodiscard]] friend constexpr auto operator>=(optional const &lhs, + optional const &rhs) + -> bool { return not(lhs < rhs); } }; diff --git a/include/stdx/rollover.hpp b/include/stdx/rollover.hpp index f6f3585..6e52e37 100644 --- a/include/stdx/rollover.hpp +++ b/include/stdx/rollover.hpp @@ -80,34 +80,39 @@ template struct rollover_t { constexpr friend auto operator>(rollover_t, rollover_t) -> bool = delete; constexpr friend auto operator>=(rollover_t, rollover_t) -> bool = delete; - [[nodiscard]] constexpr friend auto cmp_less(rollover_t lhs, - rollover_t rhs) -> bool { + [[nodiscard]] constexpr friend auto cmp_less(rollover_t lhs, rollover_t rhs) + -> bool { constexpr auto mid = static_cast(~underlying_t{}) / 2; return static_cast(lhs.value - rhs.value) > mid; } - [[nodiscard]] constexpr friend auto - operator+(rollover_t lhs, rollover_t rhs) -> rollover_t { + [[nodiscard]] constexpr friend auto operator+(rollover_t lhs, + rollover_t rhs) + -> rollover_t { lhs += rhs; return lhs; } - [[nodiscard]] constexpr friend auto - operator-(rollover_t lhs, rollover_t rhs) -> rollover_t { + [[nodiscard]] constexpr friend auto operator-(rollover_t lhs, + rollover_t rhs) + -> rollover_t { lhs -= rhs; return lhs; } - [[nodiscard]] constexpr friend auto - operator*(rollover_t lhs, rollover_t rhs) -> rollover_t { + [[nodiscard]] constexpr friend auto operator*(rollover_t lhs, + rollover_t rhs) + -> rollover_t { lhs *= rhs; return lhs; } - [[nodiscard]] constexpr friend auto - operator/(rollover_t lhs, rollover_t rhs) -> rollover_t { + [[nodiscard]] constexpr friend auto operator/(rollover_t lhs, + rollover_t rhs) + -> rollover_t { lhs /= rhs; return lhs; } - [[nodiscard]] constexpr friend auto - operator%(rollover_t lhs, rollover_t rhs) -> rollover_t { + [[nodiscard]] constexpr friend auto operator%(rollover_t lhs, + rollover_t rhs) + -> rollover_t { lhs %= rhs; return lhs; } diff --git a/include/stdx/span.hpp b/include/stdx/span.hpp index 96cd061..67bbcee 100644 --- a/include/stdx/span.hpp +++ b/include/stdx/span.hpp @@ -159,8 +159,8 @@ class span : public detail::span_base { [[nodiscard]] constexpr auto rbegin() const noexcept -> reverse_iterator { return std::reverse_iterator{end()}; } - [[nodiscard]] constexpr auto - crbegin() const noexcept -> const_reverse_iterator { + [[nodiscard]] constexpr auto crbegin() const noexcept + -> const_reverse_iterator { return std::reverse_iterator{cend()}; } @@ -173,8 +173,8 @@ class span : public detail::span_base { [[nodiscard]] constexpr auto rend() const noexcept -> reverse_iterator { return std::reverse_iterator{begin()}; } - [[nodiscard]] constexpr auto - crend() const noexcept -> const_reverse_iterator { + [[nodiscard]] constexpr auto crend() const noexcept + -> const_reverse_iterator { return std::reverse_iterator{cbegin()}; } @@ -192,8 +192,8 @@ class span : public detail::span_base { static_assert(Count <= Extent, "first cannot form a larger span!"); return span{ptr, Count}; } - [[nodiscard]] constexpr auto - first(size_type count) const -> span { + [[nodiscard]] constexpr auto first(size_type count) const + -> span { return {ptr, count}; } @@ -202,8 +202,8 @@ class span : public detail::span_base { static_assert(Count <= Extent, "last cannot form a larger span!"); return span{ptr + this->size() - Count, Count}; } - [[nodiscard]] constexpr auto - last(size_type count) const -> span { + [[nodiscard]] constexpr auto last(size_type count) const + -> span { return {ptr + this->size() - count, count}; } @@ -268,8 +268,8 @@ template using range_reference_t = iter_reference_t>; } // namespace detail template -span(It, - EndOrSize) -> span>>; +span(It, EndOrSize) + -> span>>; // NOLINTNEXTLINE(*-avoid-c-arrays) template span(T (&)[N]) -> span; template span(std::array &) -> span; diff --git a/include/stdx/tuple.hpp b/include/stdx/tuple.hpp index ec06b88..a03135e 100644 --- a/include/stdx/tuple.hpp +++ b/include/stdx/tuple.hpp @@ -59,8 +59,9 @@ template struct element { #else constexpr static auto ugly_Value(index_constant) -> T; - [[nodiscard]] constexpr auto ugly_iGet_clvr( - index_constant) const & noexcept LIFETIMEBOUND -> T const & { + [[nodiscard]] constexpr auto + ugly_iGet_clvr(index_constant) const & noexcept LIFETIMEBOUND + -> T const & { return value; } [[nodiscard]] constexpr auto @@ -75,8 +76,9 @@ template struct element { template requires(std::same_as or ... or std::same_as) - [[nodiscard]] constexpr auto ugly_tGet_clvr( - tag_constant *) const & noexcept LIFETIMEBOUND -> T const & { + [[nodiscard]] constexpr auto + ugly_tGet_clvr(tag_constant *) const & noexcept LIFETIMEBOUND + -> T const & { return value; } template @@ -103,8 +105,9 @@ template struct element { T value; private: - [[nodiscard]] friend constexpr auto - operator==(element const &, element const &) -> bool = default; + [[nodiscard]] friend constexpr auto operator==(element const &, + element const &) + -> bool = default; [[nodiscard]] friend constexpr auto operator<=>(element const &, element const &) = default; }; @@ -334,14 +337,14 @@ struct tuple_impl, index_function_list, Ts...> constexpr static auto size = std::integral_constant{}; - [[nodiscard]] constexpr static auto - fill_inner_indices(index_pair *p) -> index_pair * { + [[nodiscard]] constexpr static auto fill_inner_indices(index_pair *p) + -> index_pair * { ((p++->inner = Is), ...); return p; } [[nodiscard]] constexpr static auto - fill_outer_indices(index_pair *p, - [[maybe_unused]] std::size_t n) -> index_pair * { + fill_outer_indices(index_pair *p, [[maybe_unused]] std::size_t n) + -> index_pair * { ((p++->outer = (static_cast(Is), n)), ...); return p; } @@ -402,8 +405,8 @@ class tuple : public detail::tuple_impl, detail::index_function_list<>, Ts...> { template requires(not tuple_comparable) - [[nodiscard]] friend constexpr auto operator==(tuple const &, - U const &) -> bool = delete; + [[nodiscard]] friend constexpr auto operator==(tuple const &, U const &) + -> bool = delete; template requires(not tuple_comparable) @@ -430,14 +433,14 @@ template indexed_tuple(Ts...) -> indexed_tuple, Ts...>; template -[[nodiscard]] constexpr auto -get(Tuple &&t LIFETIMEBOUND) -> decltype(std::forward(t)[index]) { +[[nodiscard]] constexpr auto get(Tuple &&t LIFETIMEBOUND) + -> decltype(std::forward(t)[index]) { return std::forward(t)[index]; } template -[[nodiscard]] constexpr auto -get(Tuple &&t LIFETIMEBOUND) -> decltype(std::forward(t).get(tag)) { +[[nodiscard]] constexpr auto get(Tuple &&t LIFETIMEBOUND) + -> decltype(std::forward(t).get(tag)) { return std::forward(t).get(tag); } diff --git a/include/stdx/tuple_algorithms.hpp b/include/stdx/tuple_algorithms.hpp index a2f2ad3..5c302a6 100644 --- a/include/stdx/tuple_algorithms.hpp +++ b/include/stdx/tuple_algorithms.hpp @@ -93,14 +93,14 @@ template } template -[[nodiscard]] constexpr auto tuple_push_front(T &&t, - Tup &&tup) -> decltype(auto) { +[[nodiscard]] constexpr auto tuple_push_front(T &&t, Tup &&tup) + -> decltype(auto) { return tuple_cons(std::forward(t), std::forward(tup)); } template -[[nodiscard]] constexpr auto tuple_push_back(Tup &&tup, - T &&t) -> decltype(auto) { +[[nodiscard]] constexpr auto tuple_push_back(Tup &&tup, T &&t) + -> decltype(auto) { return tuple_snoc(std::forward(tup), std::forward(t)); } @@ -280,8 +280,8 @@ template typename Proj = std::type_identity_t> struct chunk { std::size_t offset{}; std::size_t size{}; - friend constexpr auto operator==(chunk const &, - chunk const &) -> bool = default; + friend constexpr auto operator==(chunk const &, chunk const &) + -> bool = default; }; template typename Proj = std::type_identity_t> diff --git a/include/stdx/type_traits.hpp b/include/stdx/type_traits.hpp index daa6207..eb4136c 100644 --- a/include/stdx/type_traits.hpp +++ b/include/stdx/type_traits.hpp @@ -101,8 +101,8 @@ constexpr bool is_value_specialization_of_v = detail::is_value_specialization_of_v; template typename T> -constexpr auto -is_specialization_of() -> std::bool_constant> { +constexpr auto is_specialization_of() + -> std::bool_constant> { return {}; } diff --git a/include/stdx/udls.hpp b/include/stdx/udls.hpp index 11e673d..22a5293 100644 --- a/include/stdx/udls.hpp +++ b/include/stdx/udls.hpp @@ -111,29 +111,29 @@ CONSTEVAL auto operator""_false(char const *, std::size_t) -> bool { } // NOLINTBEGIN(google-runtime-int) -CONSTEVAL auto -operator""_k(unsigned long long int n) -> unsigned long long int { +CONSTEVAL auto operator""_k(unsigned long long int n) + -> unsigned long long int { return n * 1'000u; } -CONSTEVAL auto -operator""_M(unsigned long long int n) -> unsigned long long int { +CONSTEVAL auto operator""_M(unsigned long long int n) + -> unsigned long long int { return n * 1'000'000u; } -CONSTEVAL auto -operator""_G(unsigned long long int n) -> unsigned long long int { +CONSTEVAL auto operator""_G(unsigned long long int n) + -> unsigned long long int { return n * 1'000'000'000u; } -CONSTEVAL auto -operator""_ki(unsigned long long int n) -> unsigned long long int { +CONSTEVAL auto operator""_ki(unsigned long long int n) + -> unsigned long long int { return n * 1'024u; } -CONSTEVAL auto -operator""_Mi(unsigned long long int n) -> unsigned long long int { +CONSTEVAL auto operator""_Mi(unsigned long long int n) + -> unsigned long long int { return n * 1'024ull * 1'024ull; } -CONSTEVAL auto -operator""_Gi(unsigned long long int n) -> unsigned long long int { +CONSTEVAL auto operator""_Gi(unsigned long long int n) + -> unsigned long long int { return n * 1'024ull * 1'024ull * 1'024ull; } diff --git a/test/detail/tuple_types.hpp b/test/detail/tuple_types.hpp index c88484d..6dcb823 100644 --- a/test/detail/tuple_types.hpp +++ b/test/detail/tuple_types.hpp @@ -6,8 +6,8 @@ struct move_only { constexpr move_only(move_only &&) = default; constexpr auto operator=(move_only &&) noexcept -> move_only & = default; - friend constexpr auto operator==(move_only const &lhs, - move_only const &rhs) -> bool { + friend constexpr auto operator==(move_only const &lhs, move_only const &rhs) + -> bool { return lhs.value == rhs.value; } diff --git a/test/optional.cpp b/test/optional.cpp index 0c406f9..679f370 100644 --- a/test/optional.cpp +++ b/test/optional.cpp @@ -332,8 +332,8 @@ struct move_only { constexpr move_only(int i) : value{i} {} constexpr move_only(move_only &&) = default; int value{}; - constexpr friend auto operator==(move_only const &x, - move_only const &y) -> bool { + constexpr friend auto operator==(move_only const &x, move_only const &y) + -> bool { return x.value == y.value; } }; @@ -342,8 +342,8 @@ struct non_movable { constexpr non_movable(int i) : value{i} {} constexpr non_movable(non_movable &&) = delete; int value{}; - constexpr friend auto operator==(non_movable const &x, - non_movable const &y) -> bool { + constexpr friend auto operator==(non_movable const &x, non_movable const &y) + -> bool { return x.value == y.value; } };