From 02749feea88ce61c1f7eeb2d61a57d8ecf07ab11 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Fri, 20 Feb 2026 00:44:26 +0900 Subject: [PATCH] Reformat code with clang-format-18 --- .github/workflows/clang-format.yml | 2 +- .../workflows/verify-generated-headers.yml | 21 +- include/xrpl/basics/Expected.h | 50 +- include/xrpl/basics/FeeUnits.h | 24 +- include/xrpl/basics/IOUAmount.h | 6 +- include/xrpl/basics/Number.h | 6 +- include/xrpl/basics/XRPAmount.h | 6 +- include/xrpl/basics/base_uint.h | 3 +- include/xrpl/basics/safe_cast.h | 4 +- include/xrpl/basics/tagged_integer.h | 3 +- .../container/detail/aged_ordered_container.h | 8 +- .../detail/aged_unordered_container.h | 10 +- include/xrpl/beast/hash/xxhasher.h | 3 +- include/xrpl/beast/unit_test.h | 2 +- include/xrpl/beast/utility/EnhancedLogging.h | 24 +- include/xrpl/beast/utility/Journal.h | 3 +- include/xrpl/json/json_value.h | 6 +- include/xrpl/protocol/AccountID.h | 2 +- include/xrpl/protocol/ApiVersion.h | 41 +- include/xrpl/protocol/MultiApiJson.h | 84 +- include/xrpl/protocol/STAmount.h | 6 +- include/xrpl/protocol/STBase.h | 6 +- include/xrpl/protocol/STObject.h | 3 +- include/xrpl/protocol/STVector256.h | 3 +- include/xrpl/protocol/TER.h | 57 +- include/xrpl/protocol/digest.h | 21 +- include/xrpl/protocol/jss.h | 52 +- include/xrpl/server/detail/BaseHTTPPeer.h | 4 +- src/libxrpl/basics/ResolverAsio.cpp | 6 +- src/libxrpl/beast/insight/NullCollector.cpp | 12 +- .../beast/utility/src/beast_Journal.cpp | 6 +- src/libxrpl/json/Writer.cpp | 3 +- src/libxrpl/protocol/STAmount.cpp | 3 +- src/libxrpl/protocol/STBase.cpp | 3 +- src/libxrpl/protocol/STCurrency.cpp | 3 +- src/libxrpl/protocol/STInteger.cpp | 12 +- src/libxrpl/protocol/STIssue.cpp | 3 +- src/libxrpl/protocol/STParsedJSON.cpp | 3 +- src/libxrpl/protocol/STPathSet.cpp | 3 +- src/libxrpl/protocol/STVector256.cpp | 3 +- src/magic/magic_enum.h | 2472 ++++++----------- src/test/app/Import_test.cpp | 16 +- src/test/app/NFTokenBurn_test.cpp | 3 +- src/test/app/Remit_test.cpp | 1 - src/test/app/SetRemarks_test.cpp | 5 +- src/test/app/ValidatorSite_test.cpp | 25 +- src/test/basics/IOUAmount_test.cpp | 95 +- src/test/basics/XRPAmount_test.cpp | 112 +- src/test/basics/base_uint_test.cpp | 3 +- src/test/beast/beast_Zero_test.cpp | 6 +- .../consensus/ByzantineFailureSim_test.cpp | 4 +- src/test/csf/Peer.h | 3 +- src/test/csf/collectors.h | 221 +- src/test/jtx/TestHelpers.h | 10 +- src/test/jtx/TrustedPublisherServer.h | 12 +- src/test/jtx/amount.h | 14 +- src/test/jtx/impl/AMM.cpp | 4 +- src/test/jtx/impl/amount.cpp | 3 +- src/test/jtx/multisign.h | 5 +- src/test/overlay/reduce_relay_test.cpp | 5 +- src/test/protocol/MultiApiJson_test.cpp | 280 +- src/test/protocol/STObject_test.cpp | 288 +- src/xrpld/app/hook/detail/HookAPI.cpp | 10 +- src/xrpld/app/hook/detail/applyHook.cpp | 40 +- src/xrpld/app/ledger/LedgerHistory.cpp | 58 +- .../app/ledger/detail/TimeoutCounter.cpp | 4 +- src/xrpld/app/main/GRPCServer.cpp | 4 +- src/xrpld/app/misc/AMMHelpers.h | 6 +- src/xrpld/app/misc/NetworkOPs.cpp | 4 +- src/xrpld/app/misc/detail/TxQ.cpp | 10 +- src/xrpld/app/misc/detail/ValidatorList.cpp | 3 +- src/xrpld/app/paths/Pathfinder.cpp | 3 +- src/xrpld/app/paths/detail/BookStep.cpp | 3 +- src/xrpld/app/paths/detail/DirectStep.cpp | 6 +- .../app/paths/detail/XRPEndpointStep.cpp | 3 +- src/xrpld/app/rdb/RelationalDatabase.h | 4 +- src/xrpld/app/tx/detail/AMMCreate.cpp | 4 +- src/xrpld/app/tx/detail/CancelOffer.cpp | 4 +- src/xrpld/app/tx/detail/Import.cpp | 4 +- src/xrpld/app/tx/detail/Payment.cpp | 22 +- src/xrpld/app/tx/detail/Remit.cpp | 3 +- src/xrpld/app/tx/detail/Transactor.cpp | 6 +- src/xrpld/app/tx/detail/URIToken.cpp | 7 +- src/xrpld/conditions/detail/PreimageSha256.h | 3 +- src/xrpld/consensus/Consensus.h | 10 +- src/xrpld/consensus/Validations.h | 3 +- src/xrpld/core/DatabaseCon.h | 3 +- src/xrpld/ledger/View.h | 3 +- src/xrpld/ledger/detail/View.cpp | 3 +- src/xrpld/nodestore/detail/DatabaseNodeImp.h | 3 +- .../nodestore/detail/DatabaseRotatingImp.h | 3 +- src/xrpld/overlay/detail/PeerImp.cpp | 6 +- src/xrpld/overlay/detail/ProtocolVersion.cpp | 2 +- src/xrpld/peerfinder/detail/Logic.h | 6 +- src/xrpld/rpc/detail/ServerHandler.cpp | 6 +- src/xrpld/shamap/detail/TaggedPointer.ipp | 20 +- src/xrpld/unity/rocksdb.h | 2 +- 97 files changed, 1778 insertions(+), 2610 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 91bbff48c..9002a6a6d 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -20,7 +20,7 @@ jobs: sudo apt-get update sudo apt-get install clang-format-${CLANG_VERSION} - name: Format first-party sources - run: find include src -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.ipp' \) -exec clang-format-${CLANG_VERSION} -i {} + + run: find include src -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.ipp' \) -not -path "src/magic/magic_enum.h" -exec clang-format-${CLANG_VERSION} -i {} + - name: Check for differences id: assert run: | diff --git a/.github/workflows/verify-generated-headers.yml b/.github/workflows/verify-generated-headers.yml index 723e7181b..861d1d2a1 100644 --- a/.github/workflows/verify-generated-headers.yml +++ b/.github/workflows/verify-generated-headers.yml @@ -18,22 +18,25 @@ jobs: generator: bash ./hook/generate_sfcodes.sh - target: hook/tts.h generator: ./hook/generate_tts.sh - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 env: - CLANG_VERSION: 10 + CLANG_VERSION: 18 name: ${{ matrix.target }} steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Download and install clang-format + - name: Install clang-format run: | - sudo apt-get update -y - sudo apt-get install -y libtinfo5 - curl -LO https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang+llvm-10.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz - tar -xf clang+llvm-10.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz - sudo mv clang+llvm-10.0.1-x86_64-linux-gnu-ubuntu-16.04 /opt/clang-10 - sudo ln -s /opt/clang-10/bin/clang-format /usr/local/bin/clang-format-10 + codename=$( lsb_release --codename --short ) + sudo tee /etc/apt/sources.list.d/llvm.list >/dev/null < - requires std::convertible_to constexpr Expected(U && r) + requires std::convertible_to + constexpr Expected(U&& r) : Base(boost::outcome_v2::success(T(std::forward(r)))) { } template - requires std::convertible_to && - (!std::is_reference_v)constexpr Expected(Unexpected e) + requires std::convertible_to && (!std::is_reference_v) + constexpr Expected(Unexpected e) : Base(boost::outcome_v2::failure(E(std::move(e.value())))) { } - constexpr bool has_value() const + constexpr bool + has_value() const { return Base::has_value(); } - constexpr T const& value() const + constexpr T const& + value() const { return Base::value(); } - constexpr T& value() + constexpr T& + value() { return Base::value(); } - constexpr E const& error() const + constexpr E const& + error() const { return Base::error(); } - constexpr E& error() + constexpr E& + error() { return Base::error(); } - constexpr explicit operator bool() const + constexpr explicit + operator bool() const { return has_value(); } @@ -181,22 +188,26 @@ public: // Add operator* and operator-> so the Expected API looks a bit more like // what std::expected is likely to look like. See: // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0323r10.html - [[nodiscard]] constexpr T& operator*() + [[nodiscard]] constexpr T& + operator*() { return this->value(); } - [[nodiscard]] constexpr T const& operator*() const + [[nodiscard]] constexpr T const& + operator*() const { return this->value(); } - [[nodiscard]] constexpr T* operator->() + [[nodiscard]] constexpr T* + operator->() { return &this->value(); } - [[nodiscard]] constexpr T const* operator->() const + [[nodiscard]] constexpr T const* + operator->() const { return &this->value(); } @@ -218,23 +229,26 @@ public: } template - requires std::convertible_to && - (!std::is_reference_v)constexpr Expected(Unexpected e) + requires std::convertible_to && (!std::is_reference_v) + constexpr Expected(Unexpected e) : Base(boost::outcome_v2::failure(E(std::move(e.value())))) { } - constexpr E const& error() const + constexpr E const& + error() const { return Base::error(); } - constexpr E& error() + constexpr E& + error() { return Base::error(); } - constexpr explicit operator bool() const + constexpr explicit + operator bool() const { return Base::has_value(); } diff --git a/include/xrpl/basics/FeeUnits.h b/include/xrpl/basics/FeeUnits.h index 9d5e6e216..c63a169f0 100644 --- a/include/xrpl/basics/FeeUnits.h +++ b/include/xrpl/basics/FeeUnits.h @@ -84,13 +84,13 @@ private: protected: template static constexpr bool is_compatible_v = - std::is_arithmetic_v&& std::is_arithmetic_v&& - std::is_convertible_v; + std::is_arithmetic_v && std::is_arithmetic_v && + std::is_convertible_v; template > static constexpr bool is_compatiblefee_v = - is_compatible_v&& - std::is_same_v; + is_compatible_v && + std::is_same_v; template using enable_if_compatible_t = @@ -110,7 +110,8 @@ public: { } - constexpr TaggedFee& operator=(beast::Zero) + constexpr TaggedFee& + operator=(beast::Zero) { fee_ = 0; return *this; @@ -250,7 +251,8 @@ public: } /** Returns true if the amount is not zero */ - explicit constexpr operator bool() const noexcept + explicit constexpr + operator bool() const noexcept { return fee_ != 0; } @@ -344,8 +346,8 @@ constexpr bool can_muldiv_source_v = template > constexpr bool can_muldiv_dest_v = - can_muldiv_source_v&& // Dest is also a source - std::is_convertible_v && + can_muldiv_source_v && // Dest is also a source + std::is_convertible_v && sizeof(typename Dest::value_type) >= sizeof(std::uint64_t); template < @@ -354,8 +356,8 @@ template < class = enable_if_unit_t, class = enable_if_unit_t> constexpr bool can_muldiv_sources_v = - can_muldiv_source_v&& can_muldiv_source_v&& std:: - is_same_v; + can_muldiv_source_v && can_muldiv_source_v && + std::is_same_v; template < class Source1, @@ -365,7 +367,7 @@ template < class = enable_if_unit_t, class = enable_if_unit_t> constexpr bool can_muldiv_v = - can_muldiv_sources_v&& can_muldiv_dest_v; + can_muldiv_sources_v && can_muldiv_dest_v; // Source and Dest can be the same by default template < diff --git a/include/xrpl/basics/IOUAmount.h b/include/xrpl/basics/IOUAmount.h index 221434aa8..e89feb123 100644 --- a/include/xrpl/basics/IOUAmount.h +++ b/include/xrpl/basics/IOUAmount.h @@ -82,7 +82,8 @@ public: operator<(IOUAmount const& other) const; /** Returns true if the amount is not zero */ - explicit operator bool() const noexcept; + explicit + operator bool() const noexcept; /** Return the sign of the amount */ int @@ -109,7 +110,8 @@ inline IOUAmount::IOUAmount(std::int64_t mantissa, int exponent) normalize(); } -inline IOUAmount& IOUAmount::operator=(beast::Zero) +inline IOUAmount& +IOUAmount::operator=(beast::Zero) { // The -100 is used to allow 0 to sort less than small positive values // which will have a large negative exponent. diff --git a/include/xrpl/basics/Number.h b/include/xrpl/basics/Number.h index 30ce3f731..5856ef325 100644 --- a/include/xrpl/basics/Number.h +++ b/include/xrpl/basics/Number.h @@ -88,8 +88,10 @@ public: static constexpr Number lowest() noexcept; - explicit operator XRPAmount() const; // round to nearest, even on tie - explicit operator rep() const; // round to nearest, even on tie + explicit + operator XRPAmount() const; // round to nearest, even on tie + explicit + operator rep() const; // round to nearest, even on tie friend constexpr bool operator==(Number const& x, Number const& y) noexcept diff --git a/include/xrpl/basics/XRPAmount.h b/include/xrpl/basics/XRPAmount.h index 1d3b32f16..9a3226951 100644 --- a/include/xrpl/basics/XRPAmount.h +++ b/include/xrpl/basics/XRPAmount.h @@ -65,7 +65,8 @@ public: { } - constexpr XRPAmount& operator=(beast::Zero) + constexpr XRPAmount& + operator=(beast::Zero) { drops_ = 0; return *this; @@ -155,7 +156,8 @@ public: } /** Returns true if the amount is not zero */ - explicit constexpr operator bool() const noexcept + explicit constexpr + operator bool() const noexcept { return drops_ != 0; } diff --git a/include/xrpl/basics/base_uint.h b/include/xrpl/basics/base_uint.h index a2576b148..03ff339f0 100644 --- a/include/xrpl/basics/base_uint.h +++ b/include/xrpl/basics/base_uint.h @@ -533,7 +533,8 @@ public: return bytes; } - base_uint& operator=(beast::Zero) + base_uint& + operator=(beast::Zero) { data_.fill(0); return *this; diff --git a/include/xrpl/basics/safe_cast.h b/include/xrpl/basics/safe_cast.h index e52bceca7..f193f1793 100644 --- a/include/xrpl/basics/safe_cast.h +++ b/include/xrpl/basics/safe_cast.h @@ -30,8 +30,8 @@ namespace ripple { template static constexpr bool is_safetocasttovalue_v = - (std::is_integral_v && std::is_integral_v)&&( - std::is_signed::value || std::is_unsigned::value) && + (std::is_integral_v && std::is_integral_v) && + (std::is_signed::value || std::is_unsigned::value) && (std::is_signed::value != std::is_signed::value ? sizeof(Dest) > sizeof(Src) : sizeof(Dest) >= sizeof(Src)); diff --git a/include/xrpl/basics/tagged_integer.h b/include/xrpl/basics/tagged_integer.h index 3ab8c5340..4629e8309 100644 --- a/include/xrpl/basics/tagged_integer.h +++ b/include/xrpl/basics/tagged_integer.h @@ -187,7 +187,8 @@ public: return *this; } - explicit operator Int() const noexcept + explicit + operator Int() const noexcept { return m_value; } diff --git a/include/xrpl/beast/container/detail/aged_ordered_container.h b/include/xrpl/beast/container/detail/aged_ordered_container.h index 90a8ea147..ad807e92c 100644 --- a/include/xrpl/beast/container/detail/aged_ordered_container.h +++ b/include/xrpl/beast/container/detail/aged_ordered_container.h @@ -846,8 +846,9 @@ public: // set template auto - insert(value_type&& value) -> typename std:: - enable_if>::type; + insert(value_type&& value) -> typename std::enable_if< + !maybe_multi && !maybe_map, + std::pair>::type; // multiset template @@ -1795,7 +1796,8 @@ template < template auto aged_ordered_container:: - insert(value_type&& value) -> typename std:: + insert(value_type&& value) -> + typename std:: enable_if>::type { typename cont_type::insert_commit_data d; diff --git a/include/xrpl/beast/container/detail/aged_unordered_container.h b/include/xrpl/beast/container/detail/aged_unordered_container.h index 45efb3f55..72e333480 100644 --- a/include/xrpl/beast/container/detail/aged_unordered_container.h +++ b/include/xrpl/beast/container/detail/aged_unordered_container.h @@ -1057,8 +1057,9 @@ public: // map, set template auto - insert(value_type&& value) -> typename std:: - enable_if>::type; + insert(value_type&& value) -> typename std::enable_if< + !maybe_multi && !maybe_map, + std::pair>::type; // multimap, multiset template @@ -2799,8 +2800,9 @@ aged_unordered_container< Clock, Hash, KeyEqual, - Allocator>::insert(value_type&& value) -> typename std:: - enable_if>::type + Allocator>::insert(value_type&& value) -> + typename std:: + enable_if>::type { maybe_rehash(1); typename cont_type::insert_commit_data d; diff --git a/include/xrpl/beast/hash/xxhasher.h b/include/xrpl/beast/hash/xxhasher.h index 1a6fc5023..30af05ef0 100644 --- a/include/xrpl/beast/hash/xxhasher.h +++ b/include/xrpl/beast/hash/xxhasher.h @@ -90,7 +90,8 @@ public: XXH3_64bits_update(state_, key, len); } - explicit operator std::size_t() noexcept + explicit + operator std::size_t() noexcept { return XXH3_64bits_digest(state_); } diff --git a/include/xrpl/beast/unit_test.h b/include/xrpl/beast/unit_test.h index eff82583e..bf33b205e 100644 --- a/include/xrpl/beast/unit_test.h +++ b/include/xrpl/beast/unit_test.h @@ -34,7 +34,7 @@ #ifndef BEAST_EXPECT #define BEAST_EXPECT_S1(x) #x #define BEAST_EXPECT_S2(x) BEAST_EXPECT_S1(x) -//#define BEAST_EXPECT(cond) {expect(cond, __FILE__ ":" ## +// #define BEAST_EXPECT(cond) {expect(cond, __FILE__ ":" ## //__LINE__);}while(false){} #define BEAST_EXPECT(cond) expect(cond, __FILE__ ":" BEAST_EXPECT_S2(__LINE__)) #endif diff --git a/include/xrpl/beast/utility/EnhancedLogging.h b/include/xrpl/beast/utility/EnhancedLogging.h index 626562f67..3c6301dd4 100644 --- a/include/xrpl/beast/utility/EnhancedLogging.h +++ b/include/xrpl/beast/utility/EnhancedLogging.h @@ -51,25 +51,23 @@ strip_source_root(const char* file) #ifdef SOURCE_ROOT_PATH constexpr const char* sourceRoot = SOURCE_ROOT_PATH; - constexpr auto strlen_constexpr = [](const char* s) constexpr - { + constexpr auto strlen_constexpr = [](const char* s) constexpr { const char* p = s; while (*p) ++p; return p - s; }; constexpr auto strncmp_constexpr = - [](const char* a, const char* b, size_t n) constexpr - { - for (size_t i = 0; i < n; ++i) - { - if (a[i] != b[i]) - return a[i] - b[i]; - if (a[i] == '\0') - break; - } - return 0; - }; + [](const char* a, const char* b, size_t n) constexpr { + for (size_t i = 0; i < n; ++i) + { + if (a[i] != b[i]) + return a[i] - b[i]; + if (a[i] == '\0') + break; + } + return 0; + }; constexpr size_t sourceRootLen = strlen_constexpr(sourceRoot); return (strncmp_constexpr(file, sourceRoot, sourceRootLen) == 0) ? file + sourceRootLen diff --git a/include/xrpl/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h index 250d018f3..9d32bb249 100644 --- a/include/xrpl/beast/utility/Journal.h +++ b/include/xrpl/beast/utility/Journal.h @@ -273,7 +273,8 @@ public: return m_sink.active(m_level); } - explicit operator bool() const + explicit + operator bool() const { return active(); } diff --git a/include/xrpl/json/json_value.h b/include/xrpl/json/json_value.h index c2f9184d7..e41994017 100644 --- a/include/xrpl/json/json_value.h +++ b/include/xrpl/json/json_value.h @@ -64,7 +64,8 @@ public: { } - constexpr operator const char*() const + constexpr + operator const char*() const { return str_; } @@ -296,7 +297,8 @@ public: /** Returns false if this is an empty array, empty object, empty string, or null. */ - explicit operator bool() const; + explicit + operator bool() const; /// Remove all object members and array elements. /// \pre type() is arrayValue, objectValue, or nullValue diff --git a/include/xrpl/protocol/AccountID.h b/include/xrpl/protocol/AccountID.h index ebe7f014d..7edf8d388 100644 --- a/include/xrpl/protocol/AccountID.h +++ b/include/xrpl/protocol/AccountID.h @@ -22,7 +22,7 @@ #include // VFALCO Uncomment when the header issues are resolved -//#include +// #include #include #include #include diff --git a/include/xrpl/protocol/ApiVersion.h b/include/xrpl/protocol/ApiVersion.h index 1cd03b065..dd09cf6bd 100644 --- a/include/xrpl/protocol/ApiVersion.h +++ b/include/xrpl/protocol/ApiVersion.h @@ -76,38 +76,35 @@ static_assert(apiMaximumValidVersion >= apiMaximumSupportedVersion); } // namespace RPC template - void - forApiVersions(Fn const& fn, Args&&... args) requires // - (maxVer >= minVer) && // - (minVer >= RPC::apiMinimumSupportedVersion) && // - (RPC::apiMaximumValidVersion >= maxVer) && - requires -{ - fn(std::integral_constant{}, - std::forward(args)...); - fn(std::integral_constant{}, - std::forward(args)...); -} +void +forApiVersions(Fn const& fn, Args&&... args) + requires // + (maxVer >= minVer) && // + (minVer >= RPC::apiMinimumSupportedVersion) && // + (RPC::apiMaximumValidVersion >= maxVer) && requires { + fn(std::integral_constant{}, + std::forward(args)...); + fn(std::integral_constant{}, + std::forward(args)...); + } { constexpr auto size = maxVer + 1 - minVer; - [&](std::index_sequence) - { + [&](std::index_sequence) { (((void)fn( std::integral_constant{}, std::forward(args)...)), ...); - } - (std::make_index_sequence{}); + }(std::make_index_sequence{}); } template void -forAllApiVersions(Fn const& fn, Args&&... args) requires requires -{ - forApiVersions< - RPC::apiMinimumSupportedVersion, - RPC::apiMaximumValidVersion>(fn, std::forward(args)...); -} +forAllApiVersions(Fn const& fn, Args&&... args) + requires requires { + forApiVersions< + RPC::apiMinimumSupportedVersion, + RPC::apiMaximumValidVersion>(fn, std::forward(args)...); + } { forApiVersions< RPC::apiMinimumSupportedVersion, diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index 4514c54ea..73c274ff7 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -80,9 +80,8 @@ struct MultiApiJson } void - set(const char* key, - auto const& - v) requires std::constructible_from + set(const char* key, auto const& v) + requires std::constructible_from { for (auto& a : this->val) a[key] = v; @@ -110,7 +109,8 @@ struct MultiApiJson unsigned int Version, typename... Args, typename Fn> - requires std::same_as, MultiApiJson> auto + requires std::same_as, MultiApiJson> + auto operator()( Json& json, std::integral_constant const version, @@ -133,7 +133,8 @@ struct MultiApiJson // integral_constant version, Json only template - requires std::same_as, MultiApiJson> auto + requires std::same_as, MultiApiJson> + auto operator()( Json& json, std::integral_constant const, @@ -151,10 +152,10 @@ struct MultiApiJson typename... Args, typename Fn> requires(!some_integral_constant) && - std::convertible_to&& std::same_as< - std::remove_cvref_t, - MultiApiJson> auto - operator()(Json& json, Version version, Fn fn, Args&&... args) const + std::convertible_to && + std::same_as, MultiApiJson> + auto + operator()(Json& json, Version version, Fn fn, Args&&... args) const -> std:: invoke_result_t { @@ -170,9 +171,10 @@ struct MultiApiJson // unsigned int version, Json only template requires(!some_integral_constant) && - std::convertible_to&& std:: - same_as, MultiApiJson> auto - operator()(Json& json, Version version, Fn fn) const + std::convertible_to && + std::same_as, MultiApiJson> + auto + operator()(Json& json, Version version, Fn fn) const -> std::invoke_result_t { assert( @@ -184,53 +186,43 @@ struct MultiApiJson auto visit() { - return [self = this](auto... args) requires requires - { - visitor( - std::declval(), - std::declval()...); - } - { - return visitor(*self, std::forward(args)...); - }; + return [self = this](auto... args) + requires requires { + visitor( + std::declval(), + std::declval()...); + } + { return visitor(*self, std::forward(args)...); }; } auto visit() const { - return [self = this](auto... args) requires requires - { - visitor( - std::declval(), - std::declval()...); - } - { - return visitor(*self, std::forward(args)...); - }; + return [self = this](auto... args) + requires requires { + visitor( + std::declval(), + std::declval()...); + } + { return visitor(*self, std::forward(args)...); }; } template - auto - visit(Args... args) - -> std::invoke_result_t requires( - sizeof...(args) > 0) && - requires - { - visitor(*this, std::forward(args)...); - } + auto + visit(Args... args) + -> std::invoke_result_t + requires(sizeof...(args) > 0) && + requires { visitor(*this, std::forward(args)...); } { return visitor(*this, std::forward(args)...); } template - auto - visit(Args... args) const -> std:: - invoke_result_t requires( - sizeof...(args) > 0) && - requires - { - visitor(*this, std::forward(args)...); - } + auto + visit(Args... args) const + -> std::invoke_result_t + requires(sizeof...(args) > 0) && + requires { visitor(*this, std::forward(args)...); } { return visitor(*this, std::forward(args)...); } diff --git a/include/xrpl/protocol/STAmount.h b/include/xrpl/protocol/STAmount.h index b5a134a15..f5a8a4f11 100644 --- a/include/xrpl/protocol/STAmount.h +++ b/include/xrpl/protocol/STAmount.h @@ -197,7 +197,8 @@ public: // //-------------------------------------------------------------------------- - explicit operator bool() const noexcept; + explicit + operator bool() const noexcept; STAmount& operator+=(STAmount const&); @@ -388,7 +389,8 @@ inline STAmount::operator Number() const return iou(); } -inline STAmount& STAmount::operator=(beast::Zero) +inline STAmount& +STAmount::operator=(beast::Zero) { clear(); return *this; diff --git a/include/xrpl/protocol/STBase.h b/include/xrpl/protocol/STBase.h index e13ef6c5b..097341384 100644 --- a/include/xrpl/protocol/STBase.h +++ b/include/xrpl/protocol/STBase.h @@ -52,11 +52,13 @@ struct JsonOptions { } - [[nodiscard]] constexpr explicit operator underlying_t() const noexcept + [[nodiscard]] constexpr explicit + operator underlying_t() const noexcept { return value; } - [[nodiscard]] constexpr explicit operator bool() const noexcept + [[nodiscard]] constexpr explicit + operator bool() const noexcept { return value != 0u; } diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index b3cef83de..a226733e9 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -539,7 +539,8 @@ public: Fields with soeDEFAULT and set to the default value will return `true` */ - explicit operator bool() const noexcept; + explicit + operator bool() const noexcept; /** Return the contained value diff --git a/include/xrpl/protocol/STVector256.h b/include/xrpl/protocol/STVector256.h index e70297a40..d81ddf977 100644 --- a/include/xrpl/protocol/STVector256.h +++ b/include/xrpl/protocol/STVector256.h @@ -65,7 +65,8 @@ public: setValue(const STVector256& v); /** Retrieve a copy of the vector we contain */ - explicit operator std::vector() const; + explicit + operator std::vector() const; std::size_t size() const; diff --git a/include/xrpl/protocol/TER.h b/include/xrpl/protocol/TER.h index 3024b034e..66a1bc8ad 100644 --- a/include/xrpl/protocol/TER.h +++ b/include/xrpl/protocol/TER.h @@ -453,7 +453,8 @@ public: } // Conversion to bool. - explicit operator bool() const + explicit + operator bool() const { return code_ < tesSUCCESS || code_ >= tecCLAIM; } @@ -499,60 +500,66 @@ public: // Only enabled if both arguments return int if TERtiInt is called with them. template constexpr auto -operator==(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator==(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) == TERtoInt(rhs); } template constexpr auto -operator!=(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator!=(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) != TERtoInt(rhs); } template constexpr auto -operator<(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator<(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) < TERtoInt(rhs); } template constexpr auto -operator<=(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator<=(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) <= TERtoInt(rhs); } template constexpr auto -operator>(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator>(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) > TERtoInt(rhs); } template constexpr auto -operator>=(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator>=(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) >= TERtoInt(rhs); } diff --git a/include/xrpl/protocol/digest.h b/include/xrpl/protocol/digest.h index f3fc2ea5c..b3c7a0141 100644 --- a/include/xrpl/protocol/digest.h +++ b/include/xrpl/protocol/digest.h @@ -55,7 +55,8 @@ public: void operator()(void const* data, std::size_t size) noexcept; - explicit operator result_type() noexcept; + explicit + operator result_type() noexcept; private: char ctx_[96]; @@ -77,7 +78,8 @@ public: void operator()(void const* data, std::size_t size) noexcept; - explicit operator result_type() noexcept; + explicit + operator result_type() noexcept; private: char ctx_[216]; @@ -99,7 +101,8 @@ public: void operator()(void const* data, std::size_t size) noexcept; - explicit operator result_type() noexcept; + explicit + operator result_type() noexcept; private: char ctx_[112]; @@ -144,7 +147,8 @@ public: h_(data, size); } - explicit operator result_type() noexcept + explicit + operator result_type() noexcept { auto const d0 = sha256_hasher::result_type(h_); ripemd160_hasher rh; @@ -184,18 +188,21 @@ public: h_(data, size); } - explicit operator result_type() noexcept + explicit + operator result_type() noexcept { auto const digest = sha512_hasher::result_type(h_); return result_type::fromVoid(digest.data()); } private: - inline void erase(std::false_type) + inline void + erase(std::false_type) { } - inline void erase(std::true_type) + inline void + erase(std::true_type) { secure_erase(&h_, sizeof(h_)); } diff --git a/include/xrpl/protocol/jss.h b/include/xrpl/protocol/jss.h index 27705372f..81df078b2 100644 --- a/include/xrpl/protocol/jss.h +++ b/include/xrpl/protocol/jss.h @@ -78,26 +78,26 @@ JSS(ClearFlag); // field. JSS(CreateCode); // field. JSS(Cron); JSS(CronSet); -JSS(DID); // ledger type. -JSS(DIDDelete); // transaction type. -JSS(DIDSet); // transaction type. -JSS(DeliverMax); // out: alias to Amount -JSS(DeliverMin); // in: TransactionSign -JSS(DepositPreauth); // transaction and ledger type. -JSS(Destination); // in: TransactionSign; field. -JSS(DirectoryNode); // ledger type. -JSS(EnableAmendment); // transaction type. -JSS(EPrice); // in: AMM Deposit option -JSS(EmitFailure); // transaction type. (cleanup emit) -JSS(Escrow); // ledger type. -JSS(EscrowCancel); // transaction type. -JSS(EscrowCreate); // transaction type. -JSS(EscrowFinish); // transaction type. -JSS(Fee); // in/out: TransactionSign; field. -JSS(FeeSettings); // ledger type. -JSS(FIELDS); // out: RPC server_definitions -JSS(Flags); // in/out: TransactionSign; field. -JSS(GenesisMint); // tt +JSS(DID); // ledger type. +JSS(DIDDelete); // transaction type. +JSS(DIDSet); // transaction type. +JSS(DeliverMax); // out: alias to Amount +JSS(DeliverMin); // in: TransactionSign +JSS(DepositPreauth); // transaction and ledger type. +JSS(Destination); // in: TransactionSign; field. +JSS(DirectoryNode); // ledger type. +JSS(EnableAmendment); // transaction type. +JSS(EPrice); // in: AMM Deposit option +JSS(EmitFailure); // transaction type. (cleanup emit) +JSS(Escrow); // ledger type. +JSS(EscrowCancel); // transaction type. +JSS(EscrowCreate); // transaction type. +JSS(EscrowFinish); // transaction type. +JSS(Fee); // in/out: TransactionSign; field. +JSS(FeeSettings); // ledger type. +JSS(FIELDS); // out: RPC server_definitions +JSS(Flags); // in/out: TransactionSign; field. +JSS(GenesisMint); // tt JSS(GenesisMints); JSS(GovernanceMarks); JSS(GovernanceFlags); @@ -332,12 +332,12 @@ JSS(children); JSS(ctid); // in/out: Tx RPC JSS(cres); JSS(cron); -JSS(currency_a); // out: BookChanges -JSS(currency_b); // out: BookChanges -JSS(currency); // in: paths/PathRequest, STAmount - // out: STPathSet, STAmount, - // AccountLines -JSS(current); // out: OwnerInfo +JSS(currency_a); // out: BookChanges +JSS(currency_b); // out: BookChanges +JSS(currency); // in: paths/PathRequest, STAmount + // out: STPathSet, STAmount, + // AccountLines +JSS(current); // out: OwnerInfo JSS(current_activities); JSS(current_ledger_size); // out: TxQ JSS(current_ledger); diff --git a/include/xrpl/server/detail/BaseHTTPPeer.h b/include/xrpl/server/detail/BaseHTTPPeer.h index 171eb7134..32ec4d300 100644 --- a/include/xrpl/server/detail/BaseHTTPPeer.h +++ b/include/xrpl/server/detail/BaseHTTPPeer.h @@ -244,7 +244,7 @@ BaseHTTPPeer::close() return post( strand_, std::bind( - (void (BaseHTTPPeer::*)(void)) & BaseHTTPPeer::close, + (void(BaseHTTPPeer::*)(void)) & BaseHTTPPeer::close, impl().shared_from_this())); boost::beast::get_lowest_layer(impl().stream_).close(); } @@ -507,7 +507,7 @@ BaseHTTPPeer::close(bool graceful) return post( strand_, std::bind( - (void (BaseHTTPPeer::*)(bool)) & + (void(BaseHTTPPeer::*)(bool)) & BaseHTTPPeer::close, impl().shared_from_this(), graceful)); diff --git a/src/libxrpl/basics/ResolverAsio.cpp b/src/libxrpl/basics/ResolverAsio.cpp index 53530da9d..7105eb12a 100644 --- a/src/libxrpl/basics/ResolverAsio.cpp +++ b/src/libxrpl/basics/ResolverAsio.cpp @@ -232,7 +232,8 @@ public: //------------------------------------------------------------------------- // Resolver - void do_stop(CompletionCounter) + void + do_stop(CompletionCounter) { assert(m_stop_called == true); @@ -330,7 +331,8 @@ public: std::string(port_first, port_last)); } - void do_work(CompletionCounter) + void + do_work(CompletionCounter) { if (m_stop_called == true) return; diff --git a/src/libxrpl/beast/insight/NullCollector.cpp b/src/libxrpl/beast/insight/NullCollector.cpp index 637cd06ec..12ea81701 100644 --- a/src/libxrpl/beast/insight/NullCollector.cpp +++ b/src/libxrpl/beast/insight/NullCollector.cpp @@ -41,7 +41,8 @@ class NullCounterImpl : public CounterImpl public: explicit NullCounterImpl() = default; - void increment(value_type) override + void + increment(value_type) override { } @@ -74,11 +75,13 @@ class NullGaugeImpl : public GaugeImpl public: explicit NullGaugeImpl() = default; - void set(value_type) override + void + set(value_type) override { } - void increment(difference_type) override + void + increment(difference_type) override { } @@ -94,7 +97,8 @@ class NullMeterImpl : public MeterImpl public: explicit NullMeterImpl() = default; - void increment(value_type) override + void + increment(value_type) override { } diff --git a/src/libxrpl/beast/utility/src/beast_Journal.cpp b/src/libxrpl/beast/utility/src/beast_Journal.cpp index 16ade667f..d8579296d 100644 --- a/src/libxrpl/beast/utility/src/beast_Journal.cpp +++ b/src/libxrpl/beast/utility/src/beast_Journal.cpp @@ -39,7 +39,8 @@ public: ~NullJournalSink() override = default; - bool active(severities::Severity) const override + bool + active(severities::Severity) const override { return false; } @@ -61,7 +62,8 @@ public: return severities::kDisabled; } - void threshold(severities::Severity) override + void + threshold(severities::Severity) override { } diff --git a/src/libxrpl/json/Writer.cpp b/src/libxrpl/json/Writer.cpp index ba7336209..2f7c0b523 100644 --- a/src/libxrpl/json/Writer.cpp +++ b/src/libxrpl/json/Writer.cpp @@ -285,7 +285,8 @@ Writer::output(double f) impl_->output({s.data(), lengthWithoutTrailingZeros(s)}); } -void Writer::output(std::nullptr_t) +void +Writer::output(std::nullptr_t) { impl_->output("null"); } diff --git a/src/libxrpl/protocol/STAmount.cpp b/src/libxrpl/protocol/STAmount.cpp index 236603d6c..bb9a24c12 100644 --- a/src/libxrpl/protocol/STAmount.cpp +++ b/src/libxrpl/protocol/STAmount.cpp @@ -650,7 +650,8 @@ STAmount::getText() const return ret; } -Json::Value STAmount::getJson(JsonOptions) const +Json::Value +STAmount::getJson(JsonOptions) const { Json::Value elem; setJson(elem); diff --git a/src/libxrpl/protocol/STBase.cpp b/src/libxrpl/protocol/STBase.cpp index b7e9c94ca..73565cbf7 100644 --- a/src/libxrpl/protocol/STBase.cpp +++ b/src/libxrpl/protocol/STBase.cpp @@ -96,7 +96,8 @@ STBase::getText() const return std::string(); } -Json::Value STBase::getJson(JsonOptions /*options*/) const +Json::Value +STBase::getJson(JsonOptions /*options*/) const { return getText(); } diff --git a/src/libxrpl/protocol/STCurrency.cpp b/src/libxrpl/protocol/STCurrency.cpp index c8fc65013..56ac19da1 100644 --- a/src/libxrpl/protocol/STCurrency.cpp +++ b/src/libxrpl/protocol/STCurrency.cpp @@ -50,7 +50,8 @@ STCurrency::getText() const return to_string(currency_); } -Json::Value STCurrency::getJson(JsonOptions) const +Json::Value +STCurrency::getJson(JsonOptions) const { return to_string(currency_); } diff --git a/src/libxrpl/protocol/STInteger.cpp b/src/libxrpl/protocol/STInteger.cpp index 7b7420006..af0c18a51 100644 --- a/src/libxrpl/protocol/STInteger.cpp +++ b/src/libxrpl/protocol/STInteger.cpp @@ -61,7 +61,8 @@ STUInt8::getText() const } template <> -Json::Value STUInt8::getJson(JsonOptions) const +Json::Value +STUInt8::getJson(JsonOptions) const { if (getFName() == sfTransactionResult) { @@ -118,7 +119,8 @@ STUInt16::getText() const } template <> -Json::Value STUInt16::getJson(JsonOptions) const +Json::Value +STUInt16::getJson(JsonOptions) const { if (getFName() == sfLedgerEntryType) { @@ -164,7 +166,8 @@ STUInt32::getText() const } template <> -Json::Value STUInt32::getJson(JsonOptions) const +Json::Value +STUInt32::getJson(JsonOptions) const { return value_; } @@ -192,7 +195,8 @@ STUInt64::getText() const } template <> -Json::Value STUInt64::getJson(JsonOptions) const +Json::Value +STUInt64::getJson(JsonOptions) const { std::string str(16, 0); auto ret = std::to_chars(str.data(), str.data() + str.size(), value_, 16); diff --git a/src/libxrpl/protocol/STIssue.cpp b/src/libxrpl/protocol/STIssue.cpp index 9dcee6498..00fe86b32 100644 --- a/src/libxrpl/protocol/STIssue.cpp +++ b/src/libxrpl/protocol/STIssue.cpp @@ -65,7 +65,8 @@ STIssue::getSType() const return STI_ISSUE; } -Json::Value STIssue::getJson(JsonOptions) const +Json::Value +STIssue::getJson(JsonOptions) const { return to_json(issue_); } diff --git a/src/libxrpl/protocol/STParsedJSON.cpp b/src/libxrpl/protocol/STParsedJSON.cpp index dec5e87ea..327b9ee31 100644 --- a/src/libxrpl/protocol/STParsedJSON.cpp +++ b/src/libxrpl/protocol/STParsedJSON.cpp @@ -967,8 +967,7 @@ parseArray( Json::Value const objectFields(json[i][objectName]); std::stringstream ss; - ss << json_name << "." - << "[" << i << "]." << objectName; + ss << json_name << "." << "[" << i << "]." << objectName; auto ret = parseObject( ss.str(), objectFields, nameField, depth + 1, error); diff --git a/src/libxrpl/protocol/STPathSet.cpp b/src/libxrpl/protocol/STPathSet.cpp index b65846527..78c47cadc 100644 --- a/src/libxrpl/protocol/STPathSet.cpp +++ b/src/libxrpl/protocol/STPathSet.cpp @@ -163,7 +163,8 @@ STPath::hasSeen( return false; } -Json::Value STPath::getJson(JsonOptions) const +Json::Value +STPath::getJson(JsonOptions) const { Json::Value ret(Json::arrayValue); diff --git a/src/libxrpl/protocol/STVector256.cpp b/src/libxrpl/protocol/STVector256.cpp index 2d8bc4ee2..385c0ef76 100644 --- a/src/libxrpl/protocol/STVector256.cpp +++ b/src/libxrpl/protocol/STVector256.cpp @@ -80,7 +80,8 @@ STVector256::isEquivalent(const STBase& t) const return v && (mValue == v->mValue); } -Json::Value STVector256::getJson(JsonOptions) const +Json::Value +STVector256::getJson(JsonOptions) const { Json::Value ret(Json::arrayValue); diff --git a/src/magic/magic_enum.h b/src/magic/magic_enum.h index 125424e44..7adf87715 100644 --- a/src/magic/magic_enum.h +++ b/src/magic/magic_enum.h @@ -11,23 +11,23 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2019 - 2024 Daniil Goncharov . // -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -// OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. #ifndef NEARGYE_MAGIC_ENUM_HPP #define NEARGYE_MAGIC_ENUM_HPP @@ -45,110 +45,90 @@ #include #if defined(MAGIC_ENUM_CONFIG_FILE) -#include MAGIC_ENUM_CONFIG_FILE +# include MAGIC_ENUM_CONFIG_FILE #endif #if !defined(MAGIC_ENUM_USING_ALIAS_OPTIONAL) -#include +# include #endif #if !defined(MAGIC_ENUM_USING_ALIAS_STRING) -#include +# include #endif #if !defined(MAGIC_ENUM_USING_ALIAS_STRING_VIEW) -#include +# include #endif #if defined(MAGIC_ENUM_NO_ASSERT) -#define MAGIC_ENUM_ASSERT(...) static_cast(0) +# define MAGIC_ENUM_ASSERT(...) static_cast(0) #elif !defined(MAGIC_ENUM_ASSERT) -#include -#define MAGIC_ENUM_ASSERT(...) assert((__VA_ARGS__)) +# include +# define MAGIC_ENUM_ASSERT(...) assert((__VA_ARGS__)) #endif #if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunknown-warning-option" -#pragma clang diagnostic ignored "-Wenum-constexpr-conversion" -#pragma clang diagnostic ignored \ - "-Wuseless-cast" // suppresses 'static_cast('\0')' for char_type - // = char (common on Linux). +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunknown-warning-option" +# pragma clang diagnostic ignored "-Wenum-constexpr-conversion" +# pragma clang diagnostic ignored "-Wuseless-cast" // suppresses 'static_cast('\0')' for char_type = char (common on Linux). #elif defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored \ - "-Wmaybe-uninitialized" // May be used uninitialized 'return {};'. -#pragma GCC diagnostic ignored \ - "-Wuseless-cast" // suppresses 'static_cast('\0')' for char_type - // = char (common on Linux). +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // May be used uninitialized 'return {};'. +# pragma GCC diagnostic ignored "-Wuseless-cast" // suppresses 'static_cast('\0')' for char_type = char (common on Linux). #elif defined(_MSC_VER) -#pragma warning(push) -#pragma warning( \ - disable : 26495) // Variable 'static_str::chars_' is uninitialized. -#pragma warning( \ - disable : 28020) // Arithmetic overflow: Using operator '-' on a 4 byte - // value and then casting the result to a 8 byte value. -#pragma warning( \ - disable : 26451) // The expression '0<=_Param_(1)&&_Param_(1)<=1-1' is not - // true at this call. -#pragma warning( \ - disable : 4514) // Unreferenced inline function has been removed. +# pragma warning(push) +# pragma warning(disable : 26495) // Variable 'static_str::chars_' is uninitialized. +# pragma warning(disable : 28020) // Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. +# pragma warning(disable : 26451) // The expression '0<=_Param_(1)&&_Param_(1)<=1-1' is not true at this call. +# pragma warning(disable : 4514) // Unreferenced inline function has been removed. #endif // Checks magic_enum compiler compatibility. -#if defined(__clang__) && __clang_major__ >= 5 || \ - defined(__GNUC__) && __GNUC__ >= 9 || \ - defined(_MSC_VER) && _MSC_VER >= 1910 || defined(__RESHARPER__) -#undef MAGIC_ENUM_SUPPORTED -#define MAGIC_ENUM_SUPPORTED 1 +#if defined(__clang__) && __clang_major__ >= 5 || defined(__GNUC__) && __GNUC__ >= 9 || defined(_MSC_VER) && _MSC_VER >= 1910 || defined(__RESHARPER__) +# undef MAGIC_ENUM_SUPPORTED +# define MAGIC_ENUM_SUPPORTED 1 #endif // Checks magic_enum compiler aliases compatibility. -#if defined(__clang__) && __clang_major__ >= 5 || \ - defined(__GNUC__) && __GNUC__ >= 9 || \ - defined(_MSC_VER) && _MSC_VER >= 1920 -#undef MAGIC_ENUM_SUPPORTED_ALIASES -#define MAGIC_ENUM_SUPPORTED_ALIASES 1 +#if defined(__clang__) && __clang_major__ >= 5 || defined(__GNUC__) && __GNUC__ >= 9 || defined(_MSC_VER) && _MSC_VER >= 1920 +# undef MAGIC_ENUM_SUPPORTED_ALIASES +# define MAGIC_ENUM_SUPPORTED_ALIASES 1 #endif -// Enum value must be greater or equals than MAGIC_ENUM_RANGE_MIN. By default -// MAGIC_ENUM_RANGE_MIN = -128. If need another min range for all enum types by -// default, redefine the macro MAGIC_ENUM_RANGE_MIN. +// Enum value must be greater or equals than MAGIC_ENUM_RANGE_MIN. By default MAGIC_ENUM_RANGE_MIN = -128. +// If need another min range for all enum types by default, redefine the macro MAGIC_ENUM_RANGE_MIN. #if !defined(MAGIC_ENUM_RANGE_MIN) -#define MAGIC_ENUM_RANGE_MIN -128 +# define MAGIC_ENUM_RANGE_MIN -128 #endif -// Enum value must be less or equals than MAGIC_ENUM_RANGE_MAX. By default -// MAGIC_ENUM_RANGE_MAX = 128. If need another max range for all enum types by -// default, redefine the macro MAGIC_ENUM_RANGE_MAX. +// Enum value must be less or equals than MAGIC_ENUM_RANGE_MAX. By default MAGIC_ENUM_RANGE_MAX = 128. +// If need another max range for all enum types by default, redefine the macro MAGIC_ENUM_RANGE_MAX. #if !defined(MAGIC_ENUM_RANGE_MAX) -#define MAGIC_ENUM_RANGE_MAX 127 +# define MAGIC_ENUM_RANGE_MAX 127 #endif -// Improve ReSharper C++ intellisense performance with builtins, avoiding -// unnecessary template instantiations. +// Improve ReSharper C++ intellisense performance with builtins, avoiding unnecessary template instantiations. #if defined(__RESHARPER__) -#undef MAGIC_ENUM_GET_ENUM_NAME_BUILTIN -#undef MAGIC_ENUM_GET_TYPE_NAME_BUILTIN -#if __RESHARPER__ >= 20230100 -#define MAGIC_ENUM_GET_ENUM_NAME_BUILTIN(V) __rscpp_enumerator_name(V) -#define MAGIC_ENUM_GET_TYPE_NAME_BUILTIN(T) __rscpp_type_name() -#else -#define MAGIC_ENUM_GET_ENUM_NAME_BUILTIN(V) nullptr -#define MAGIC_ENUM_GET_TYPE_NAME_BUILTIN(T) nullptr -#endif +# undef MAGIC_ENUM_GET_ENUM_NAME_BUILTIN +# undef MAGIC_ENUM_GET_TYPE_NAME_BUILTIN +# if __RESHARPER__ >= 20230100 +# define MAGIC_ENUM_GET_ENUM_NAME_BUILTIN(V) __rscpp_enumerator_name(V) +# define MAGIC_ENUM_GET_TYPE_NAME_BUILTIN(T) __rscpp_type_name() +# else +# define MAGIC_ENUM_GET_ENUM_NAME_BUILTIN(V) nullptr +# define MAGIC_ENUM_GET_TYPE_NAME_BUILTIN(T) nullptr +# endif #endif namespace magic_enum { -// If need another optional type, define the macro -// MAGIC_ENUM_USING_ALIAS_OPTIONAL. +// If need another optional type, define the macro MAGIC_ENUM_USING_ALIAS_OPTIONAL. #if defined(MAGIC_ENUM_USING_ALIAS_OPTIONAL) MAGIC_ENUM_USING_ALIAS_OPTIONAL #else using std::optional; #endif -// If need another string_view type, define the macro -// MAGIC_ENUM_USING_ALIAS_STRING_VIEW. +// If need another string_view type, define the macro MAGIC_ENUM_USING_ALIAS_STRING_VIEW. #if defined(MAGIC_ENUM_USING_ALIAS_STRING_VIEW) MAGIC_ENUM_USING_ALIAS_STRING_VIEW #else @@ -163,1052 +143,666 @@ using std::string; #endif using char_type = string_view::value_type; -static_assert( - std::is_same_v, - "magic_enum::customize requires same string_view::value_type and " - "string::value_type"); -static_assert( - [] { - if constexpr (std::is_same_v) - { - constexpr const char c[] = - "abcdefghijklmnopqrstuvwxyz_" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789|"; - constexpr const wchar_t wc[] = - L"abcdefghijklmnopqrstuvwxyz_" - L"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789|"; - static_assert( - std::size(c) == std::size(wc), - "magic_enum::customize identifier characters are multichars in " - "wchar_t."); +static_assert(std::is_same_v, "magic_enum::customize requires same string_view::value_type and string::value_type"); +static_assert([] { + if constexpr (std::is_same_v) { + constexpr const char c[] = "abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789|"; + constexpr const wchar_t wc[] = L"abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789|"; + static_assert(std::size(c) == std::size(wc), "magic_enum::customize identifier characters are multichars in wchar_t."); - for (std::size_t i = 0; i < std::size(c); ++i) - { - if (c[i] != wc[i]) - { - return false; - } - } - } - return true; - }(), - "magic_enum::customize wchar_t is not compatible with ASCII."); + for (std::size_t i = 0; i < std::size(c); ++i) { + if (c[i] != wc[i]) { + return false; + } + } + } + return true; +} (), "magic_enum::customize wchar_t is not compatible with ASCII."); namespace customize { -// Enum value must be in range [MAGIC_ENUM_RANGE_MIN, MAGIC_ENUM_RANGE_MAX]. By -// default MAGIC_ENUM_RANGE_MIN = -128, MAGIC_ENUM_RANGE_MAX = 128. If need -// another range for all enum types by default, redefine the macro -// MAGIC_ENUM_RANGE_MIN and MAGIC_ENUM_RANGE_MAX. If need another range for -// specific enum type, add specialization enum_range for necessary enum type. +// Enum value must be in range [MAGIC_ENUM_RANGE_MIN, MAGIC_ENUM_RANGE_MAX]. By default MAGIC_ENUM_RANGE_MIN = -128, MAGIC_ENUM_RANGE_MAX = 128. +// If need another range for all enum types by default, redefine the macro MAGIC_ENUM_RANGE_MIN and MAGIC_ENUM_RANGE_MAX. +// If need another range for specific enum type, add specialization enum_range for necessary enum type. template -struct enum_range -{ - static constexpr int min = MAGIC_ENUM_RANGE_MIN; - static constexpr int max = MAGIC_ENUM_RANGE_MAX; +struct enum_range { + static constexpr int min = MAGIC_ENUM_RANGE_MIN; + static constexpr int max = MAGIC_ENUM_RANGE_MAX; }; -static_assert( - MAGIC_ENUM_RANGE_MAX > MAGIC_ENUM_RANGE_MIN, - "MAGIC_ENUM_RANGE_MAX must be greater than MAGIC_ENUM_RANGE_MIN."); +static_assert(MAGIC_ENUM_RANGE_MAX > MAGIC_ENUM_RANGE_MIN, "MAGIC_ENUM_RANGE_MAX must be greater than MAGIC_ENUM_RANGE_MIN."); namespace detail { -enum class customize_tag { default_tag, invalid_tag, custom_tag }; +enum class customize_tag { + default_tag, + invalid_tag, + custom_tag +}; -} // namespace detail +} // namespace magic_enum::customize::detail -class customize_t : public std::pair -{ -public: - constexpr customize_t(string_view srt) - : std::pair{ - detail::customize_tag::custom_tag, - srt} - { - } - constexpr customize_t(const char_type* srt) : customize_t{string_view{srt}} - { - } - constexpr customize_t(detail::customize_tag tag) - : std::pair{tag, string_view{}} - { - MAGIC_ENUM_ASSERT(tag != detail::customize_tag::custom_tag); - } +class customize_t : public std::pair { + public: + constexpr customize_t(string_view srt) : std::pair{detail::customize_tag::custom_tag, srt} {} + constexpr customize_t(const char_type* srt) : customize_t{string_view{srt}} {} + constexpr customize_t(detail::customize_tag tag) : std::pair{tag, string_view{}} { + MAGIC_ENUM_ASSERT(tag != detail::customize_tag::custom_tag); + } }; // Default customize. -inline constexpr auto default_tag = - customize_t{detail::customize_tag::default_tag}; +inline constexpr auto default_tag = customize_t{detail::customize_tag::default_tag}; // Invalid customize. -inline constexpr auto invalid_tag = - customize_t{detail::customize_tag::invalid_tag}; +inline constexpr auto invalid_tag = customize_t{detail::customize_tag::invalid_tag}; -// If need custom names for enum, add specialization enum_name for necessary -// enum type. +// If need custom names for enum, add specialization enum_name for necessary enum type. template -constexpr customize_t enum_name(E) noexcept -{ - return default_tag; +constexpr customize_t enum_name(E) noexcept { + return default_tag; } -// If need custom type name for enum, add specialization enum_type_name for -// necessary enum type. +// If need custom type name for enum, add specialization enum_type_name for necessary enum type. template -constexpr customize_t -enum_type_name() noexcept -{ - return default_tag; +constexpr customize_t enum_type_name() noexcept { + return default_tag; } -} // namespace customize +} // namespace magic_enum::customize namespace detail { template struct supported -#if defined(MAGIC_ENUM_SUPPORTED) && MAGIC_ENUM_SUPPORTED || \ - defined(MAGIC_ENUM_NO_CHECK_SUPPORT) - : std::true_type -{ -}; +#if defined(MAGIC_ENUM_SUPPORTED) && MAGIC_ENUM_SUPPORTED || defined(MAGIC_ENUM_NO_CHECK_SUPPORT) + : std::true_type {}; #else - : std::false_type -{ -}; + : std::false_type {}; #endif -template < - auto V, - typename E = std::decay_t, - std::enable_if_t, int> = 0> +template , std::enable_if_t, int> = 0> using enum_constant = std::integral_constant; template inline constexpr bool always_false_v = false; template -struct has_is_flags : std::false_type -{ -}; +struct has_is_flags : std::false_type {}; template -struct has_is_flags< - T, - std::void_t::is_flags)>> - : std::bool_constant::is_flags)>>> -{ -}; +struct has_is_flags::is_flags)>> : std::bool_constant::is_flags)>>> {}; template -struct range_min : std::integral_constant -{ -}; +struct range_min : std::integral_constant {}; template -struct range_min::min)>> - : std::integral_constant< - decltype(customize::enum_range::min), - customize::enum_range::min> -{ -}; +struct range_min::min)>> : std::integral_constant::min), customize::enum_range::min> {}; template -struct range_max : std::integral_constant -{ -}; +struct range_max : std::integral_constant {}; template -struct range_max::max)>> - : std::integral_constant< - decltype(customize::enum_range::max), - customize::enum_range::max> -{ -}; +struct range_max::max)>> : std::integral_constant::max), customize::enum_range::max> {}; -struct str_view -{ - const char* str_ = nullptr; - std::size_t size_ = 0; +struct str_view { + const char* str_ = nullptr; + std::size_t size_ = 0; }; template -class static_str -{ -public: - constexpr explicit static_str(str_view str) noexcept - : static_str{str.str_, std::make_integer_sequence{}} - { - MAGIC_ENUM_ASSERT(str.size_ == N); - } +class static_str { + public: + constexpr explicit static_str(str_view str) noexcept : static_str{str.str_, std::make_integer_sequence{}} { + MAGIC_ENUM_ASSERT(str.size_ == N); + } - constexpr explicit static_str(string_view str) noexcept - : static_str{str.data(), std::make_integer_sequence{}} - { - MAGIC_ENUM_ASSERT(str.size() == N); - } + constexpr explicit static_str(string_view str) noexcept : static_str{str.data(), std::make_integer_sequence{}} { + MAGIC_ENUM_ASSERT(str.size() == N); + } - constexpr const char_type* - data() const noexcept - { - return chars_; - } + constexpr const char_type* data() const noexcept { return chars_; } - constexpr std::uint16_t - size() const noexcept - { - return N; - } + constexpr std::uint16_t size() const noexcept { return N; } - constexpr operator string_view() const noexcept - { - return {data(), size()}; - } + constexpr operator string_view() const noexcept { return {data(), size()}; } -private: - template - constexpr static_str( - const char* str, - std::integer_sequence) noexcept - : chars_{ - static_cast(str[I])..., - static_cast('\0')} - { - } + private: + template + constexpr static_str(const char* str, std::integer_sequence) noexcept : chars_{static_cast(str[I])..., static_cast('\0')} {} - template - constexpr static_str( - string_view str, - std::integer_sequence) noexcept - : chars_{str[I]..., static_cast('\0')} - { - } + template + constexpr static_str(string_view str, std::integer_sequence) noexcept : chars_{str[I]..., static_cast('\0')} {} - char_type chars_[static_cast(N) + 1]; + char_type chars_[static_cast(N) + 1]; }; template <> -class static_str<0> -{ -public: - constexpr explicit static_str() = default; +class static_str<0> { + public: + constexpr explicit static_str() = default; - constexpr explicit static_str(str_view) noexcept - { - } + constexpr explicit static_str(str_view) noexcept {} - constexpr explicit static_str(string_view) noexcept - { - } + constexpr explicit static_str(string_view) noexcept {} - constexpr const char_type* - data() const noexcept - { - return nullptr; - } + constexpr const char_type* data() const noexcept { return nullptr; } - constexpr std::uint16_t - size() const noexcept - { - return 0; - } + constexpr std::uint16_t size() const noexcept { return 0; } - constexpr operator string_view() const noexcept - { - return {}; - } + constexpr operator string_view() const noexcept { return {}; } }; template > -class case_insensitive -{ - static constexpr char_type - to_lower(char_type c) noexcept - { - return (c >= static_cast('A') && - c <= static_cast('Z')) - ? static_cast( - c + - (static_cast('a') - static_cast('A'))) - : c; - } +class case_insensitive { + static constexpr char_type to_lower(char_type c) noexcept { + return (c >= static_cast('A') && c <= static_cast('Z')) ? static_cast(c + (static_cast('a') - static_cast('A'))) : c; + } -public: - template - constexpr auto - operator()(L lhs, R rhs) const noexcept -> std::enable_if_t< - std::is_same_v, char_type> && - std::is_same_v, char_type>, - bool> - { - return Op{}(to_lower(lhs), to_lower(rhs)); - } + public: + template + constexpr auto operator()(L lhs, R rhs) const noexcept -> std::enable_if_t, char_type> && std::is_same_v, char_type>, bool> { + return Op{}(to_lower(lhs), to_lower(rhs)); + } }; -constexpr std::size_t -find(string_view str, char_type c) noexcept -{ -#if defined(__clang__) && __clang_major__ < 9 && defined(__GLIBCXX__) || \ - defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__) - // https://stackoverflow.com/questions/56484834/constexpr-stdstring-viewfind-last-of-doesnt-work-on-clang-8-with-libstdc - // https://developercommunity.visualstudio.com/content/problem/360432/vs20178-regression-c-failed-in-test.html - constexpr bool workaround = true; +constexpr std::size_t find(string_view str, char_type c) noexcept { +#if defined(__clang__) && __clang_major__ < 9 && defined(__GLIBCXX__) || defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__) +// https://stackoverflow.com/questions/56484834/constexpr-stdstring-viewfind-last-of-doesnt-work-on-clang-8-with-libstdc +// https://developercommunity.visualstudio.com/content/problem/360432/vs20178-regression-c-failed-in-test.html + constexpr bool workaround = true; #else - constexpr bool workaround = false; + constexpr bool workaround = false; #endif - if constexpr (workaround) - { - for (std::size_t i = 0; i < str.size(); ++i) - { - if (str[i] == c) - { - return i; - } - } - - return string_view::npos; - } - else - { - return str.find(c); + if constexpr (workaround) { + for (std::size_t i = 0; i < str.size(); ++i) { + if (str[i] == c) { + return i; + } } + + return string_view::npos; + } else { + return str.find(c); + } } template -constexpr bool -is_default_predicate() noexcept -{ - return std::is_same_v< - std::decay_t, - std::equal_to> || - std::is_same_v, std::equal_to<>>; +constexpr bool is_default_predicate() noexcept { + return std::is_same_v, std::equal_to> || + std::is_same_v, std::equal_to<>>; } template -constexpr bool -is_nothrow_invocable() -{ - return is_default_predicate() || - std::is_nothrow_invocable_r_v< - bool, - BinaryPredicate, - char_type, - char_type>; +constexpr bool is_nothrow_invocable() { + return is_default_predicate() || + std::is_nothrow_invocable_r_v; } template -constexpr bool -cmp_equal( - string_view lhs, - string_view rhs, - [[maybe_unused]] BinaryPredicate&& - p) noexcept(is_nothrow_invocable()) -{ +constexpr bool cmp_equal(string_view lhs, string_view rhs, [[maybe_unused]] BinaryPredicate&& p) noexcept(is_nothrow_invocable()) { #if defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__) - // https://developercommunity.visualstudio.com/content/problem/360432/vs20178-regression-c-failed-in-test.html - // https://developercommunity.visualstudio.com/content/problem/232218/c-constexpr-string-view.html - constexpr bool workaround = true; + // https://developercommunity.visualstudio.com/content/problem/360432/vs20178-regression-c-failed-in-test.html + // https://developercommunity.visualstudio.com/content/problem/232218/c-constexpr-string-view.html + constexpr bool workaround = true; #else - constexpr bool workaround = false; + constexpr bool workaround = false; #endif - if constexpr (!is_default_predicate() || workaround) - { - if (lhs.size() != rhs.size()) - { - return false; - } - - const auto size = lhs.size(); - for (std::size_t i = 0; i < size; ++i) - { - if (!p(lhs[i], rhs[i])) - { - return false; - } - } - - return true; + if constexpr (!is_default_predicate() || workaround) { + if (lhs.size() != rhs.size()) { + return false; } - else - { - return lhs == rhs; + + const auto size = lhs.size(); + for (std::size_t i = 0; i < size; ++i) { + if (!p(lhs[i], rhs[i])) { + return false; + } } + + return true; + } else { + return lhs == rhs; + } } template -constexpr bool -cmp_less(L lhs, R rhs) noexcept -{ - static_assert( - std::is_integral_v && std::is_integral_v, - "magic_enum::detail::cmp_less requires integral type."); +constexpr bool cmp_less(L lhs, R rhs) noexcept { + static_assert(std::is_integral_v && std::is_integral_v, "magic_enum::detail::cmp_less requires integral type."); - if constexpr (std::is_signed_v == std::is_signed_v) - { - // If same signedness (both signed or both unsigned). - return lhs < rhs; - } - else if constexpr (std::is_same_v) - { // bool special case - return static_cast(lhs) < rhs; - } - else if constexpr (std::is_same_v) - { // bool special case - return lhs < static_cast(rhs); - } - else if constexpr (std::is_signed_v) - { - // If 'right' is negative, then result is 'false', otherwise cast & - // compare. - return rhs > 0 && lhs < static_cast>(rhs); - } - else - { - // If 'left' is negative, then result is 'true', otherwise cast & - // compare. - return lhs < 0 || static_cast>(lhs) < rhs; - } + if constexpr (std::is_signed_v == std::is_signed_v) { + // If same signedness (both signed or both unsigned). + return lhs < rhs; + } else if constexpr (std::is_same_v) { // bool special case + return static_cast(lhs) < rhs; + } else if constexpr (std::is_same_v) { // bool special case + return lhs < static_cast(rhs); + } else if constexpr (std::is_signed_v) { + // If 'right' is negative, then result is 'false', otherwise cast & compare. + return rhs > 0 && lhs < static_cast>(rhs); + } else { + // If 'left' is negative, then result is 'true', otherwise cast & compare. + return lhs < 0 || static_cast>(lhs) < rhs; + } } template -constexpr I -log2(I value) noexcept -{ - static_assert( - std::is_integral_v, - "magic_enum::detail::log2 requires integral type."); +constexpr I log2(I value) noexcept { + static_assert(std::is_integral_v, "magic_enum::detail::log2 requires integral type."); - if constexpr (std::is_same_v) - { // bool special case - return MAGIC_ENUM_ASSERT(false), value; - } - else - { - auto ret = I{0}; - for (; value > I{1}; value >>= I{1}, ++ret) - { - } + if constexpr (std::is_same_v) { // bool special case + return MAGIC_ENUM_ASSERT(false), value; + } else { + auto ret = I{0}; + for (; value > I{1}; value >>= I{1}, ++ret) {} - return ret; - } + return ret; + } } #if defined(__cpp_lib_array_constexpr) && __cpp_lib_array_constexpr >= 201603L -#define MAGIC_ENUM_ARRAY_CONSTEXPR 1 +# define MAGIC_ENUM_ARRAY_CONSTEXPR 1 #else template -constexpr std::array, N> to_array( - T (&a)[N], - std::index_sequence) noexcept -{ - return {{a[I]...}}; +constexpr std::array, N> to_array(T (&a)[N], std::index_sequence) noexcept { + return {{a[I]...}}; } #endif template -inline constexpr bool is_enum_v = - std::is_enum_v&& std::is_same_v>; +inline constexpr bool is_enum_v = std::is_enum_v && std::is_same_v>; template -constexpr auto -n() noexcept -{ - static_assert(is_enum_v, "magic_enum::detail::n requires enum type."); +constexpr auto n() noexcept { + static_assert(is_enum_v, "magic_enum::detail::n requires enum type."); - if constexpr (supported::value) - { + if constexpr (supported::value) { #if defined(MAGIC_ENUM_GET_TYPE_NAME_BUILTIN) - constexpr auto name_ptr = MAGIC_ENUM_GET_TYPE_NAME_BUILTIN(E); - constexpr auto name = name_ptr - ? str_view{name_ptr, std::char_traits::length(name_ptr)} - : str_view{}; + constexpr auto name_ptr = MAGIC_ENUM_GET_TYPE_NAME_BUILTIN(E); + constexpr auto name = name_ptr ? str_view{name_ptr, std::char_traits::length(name_ptr)} : str_view{}; #elif defined(__clang__) - str_view name; - if constexpr (sizeof(__PRETTY_FUNCTION__) == sizeof(__FUNCTION__)) - { - static_assert( - always_false_v, - "magic_enum::detail::n requires __PRETTY_FUNCTION__."); - return str_view{}; - } - else - { - name.size_ = sizeof(__PRETTY_FUNCTION__) - 36; - name.str_ = __PRETTY_FUNCTION__ + 34; - } + str_view name; + if constexpr (sizeof(__PRETTY_FUNCTION__) == sizeof(__FUNCTION__)) { + static_assert(always_false_v, "magic_enum::detail::n requires __PRETTY_FUNCTION__."); + return str_view{}; + } else { + name.size_ = sizeof(__PRETTY_FUNCTION__) - 36; + name.str_ = __PRETTY_FUNCTION__ + 34; + } #elif defined(__GNUC__) - auto name = - str_view{__PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1}; - if constexpr (sizeof(__PRETTY_FUNCTION__) == sizeof(__FUNCTION__)) - { - static_assert( - always_false_v, - "magic_enum::detail::n requires __PRETTY_FUNCTION__."); - return str_view{}; - } - else if (name.str_[name.size_ - 1] == ']') - { - name.size_ -= 50; - name.str_ += 49; - } - else - { - name.size_ -= 40; - name.str_ += 37; - } + auto name = str_view{__PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1}; + if constexpr (sizeof(__PRETTY_FUNCTION__) == sizeof(__FUNCTION__)) { + static_assert(always_false_v, "magic_enum::detail::n requires __PRETTY_FUNCTION__."); + return str_view{}; + } else if (name.str_[name.size_ - 1] == ']') { + name.size_ -= 50; + name.str_ += 49; + } else { + name.size_ -= 40; + name.str_ += 37; + } #elif defined(_MSC_VER) - // CLI/C++ workaround (see - // https://github.com/Neargye/magic_enum/issues/284). - str_view name; - name.str_ = __FUNCSIG__; - name.str_ += 40; - name.size_ += sizeof(__FUNCSIG__) - 57; + // CLI/C++ workaround (see https://github.com/Neargye/magic_enum/issues/284). + str_view name; + name.str_ = __FUNCSIG__; + name.str_ += 40; + name.size_ += sizeof(__FUNCSIG__) - 57; #else - auto name = str_view{}; + auto name = str_view{}; #endif - std::size_t p = 0; - for (std::size_t i = name.size_; i > 0; --i) - { - if (name.str_[i] == ':') - { - p = i + 1; - break; - } - } - if (p > 0) - { - name.size_ -= p; - name.str_ += p; - } - return name; + std::size_t p = 0; + for (std::size_t i = name.size_; i > 0; --i) { + if (name.str_[i] == ':') { + p = i + 1; + break; + } } - else - { - return str_view{}; // Unsupported compiler or Invalid customize. + if (p > 0) { + name.size_ -= p; + name.str_ += p; } + return name; + } else { + return str_view{}; // Unsupported compiler or Invalid customize. + } } template -constexpr auto -type_name() noexcept -{ - [[maybe_unused]] constexpr auto custom = customize::enum_type_name(); - static_assert( - std::is_same_v, customize::customize_t>, - "magic_enum::customize requires customize_t type."); - if constexpr (custom.first == customize::detail::customize_tag::custom_tag) - { - constexpr auto name = custom.second; - static_assert( - !name.empty(), "magic_enum::customize requires not empty string."); - return static_str{name}; - } - else if constexpr ( - custom.first == customize::detail::customize_tag::invalid_tag) - { - return static_str<0>{}; - } - else if constexpr ( - custom.first == customize::detail::customize_tag::default_tag) - { - constexpr auto name = n(); - return static_str{name}; - } - else - { - static_assert(always_false_v, "magic_enum::customize invalid."); - } +constexpr auto type_name() noexcept { + [[maybe_unused]] constexpr auto custom = customize::enum_type_name(); + static_assert(std::is_same_v, customize::customize_t>, "magic_enum::customize requires customize_t type."); + if constexpr (custom.first == customize::detail::customize_tag::custom_tag) { + constexpr auto name = custom.second; + static_assert(!name.empty(), "magic_enum::customize requires not empty string."); + return static_str{name}; + } else if constexpr (custom.first == customize::detail::customize_tag::invalid_tag) { + return static_str<0>{}; + } else if constexpr (custom.first == customize::detail::customize_tag::default_tag) { + constexpr auto name = n(); + return static_str{name}; + } else { + static_assert(always_false_v, "magic_enum::customize invalid."); + } } template inline constexpr auto type_name_v = type_name(); template -constexpr auto -n() noexcept -{ - static_assert( - is_enum_v, "magic_enum::detail::n requires enum type."); +constexpr auto n() noexcept { + static_assert(is_enum_v, "magic_enum::detail::n requires enum type."); - if constexpr (supported::value) - { + if constexpr (supported::value) { #if defined(MAGIC_ENUM_GET_ENUM_NAME_BUILTIN) - constexpr auto name_ptr = MAGIC_ENUM_GET_ENUM_NAME_BUILTIN(V); - auto name = name_ptr - ? str_view{name_ptr, std::char_traits::length(name_ptr)} - : str_view{}; + constexpr auto name_ptr = MAGIC_ENUM_GET_ENUM_NAME_BUILTIN(V); + auto name = name_ptr ? str_view{name_ptr, std::char_traits::length(name_ptr)} : str_view{}; #elif defined(__clang__) - str_view name; - if constexpr (sizeof(__PRETTY_FUNCTION__) == sizeof(__FUNCTION__)) - { - static_assert( - always_false_v, - "magic_enum::detail::n requires __PRETTY_FUNCTION__."); - return str_view{}; - } - else - { - name.size_ = sizeof(__PRETTY_FUNCTION__) - 36; - name.str_ = __PRETTY_FUNCTION__ + 34; - } - if (name.size_ > 22 && name.str_[0] == '(' && name.str_[1] == 'a' && - name.str_[10] == ' ' && name.str_[22] == ':') - { - name.size_ -= 23; - name.str_ += 23; - } - if (name.str_[0] == '(' || name.str_[0] == '-' || - (name.str_[0] >= '0' && name.str_[0] <= '9')) - { - name = str_view{}; - } + str_view name; + if constexpr (sizeof(__PRETTY_FUNCTION__) == sizeof(__FUNCTION__)) { + static_assert(always_false_v, "magic_enum::detail::n requires __PRETTY_FUNCTION__."); + return str_view{}; + } else { + name.size_ = sizeof(__PRETTY_FUNCTION__) - 36; + name.str_ = __PRETTY_FUNCTION__ + 34; + } + if (name.size_ > 22 && name.str_[0] == '(' && name.str_[1] == 'a' && name.str_[10] == ' ' && name.str_[22] == ':') { + name.size_ -= 23; + name.str_ += 23; + } + if (name.str_[0] == '(' || name.str_[0] == '-' || (name.str_[0] >= '0' && name.str_[0] <= '9')) { + name = str_view{}; + } #elif defined(__GNUC__) - auto name = - str_view{__PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1}; - if constexpr (sizeof(__PRETTY_FUNCTION__) == sizeof(__FUNCTION__)) - { - static_assert( - always_false_v, - "magic_enum::detail::n requires __PRETTY_FUNCTION__."); - return str_view{}; - } - else if (name.str_[name.size_ - 1] == ']') - { - name.size_ -= 55; - name.str_ += 54; - } - else - { - name.size_ -= 40; - name.str_ += 37; - } - if (name.str_[0] == '(') - { - name = str_view{}; - } + auto name = str_view{__PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1}; + if constexpr (sizeof(__PRETTY_FUNCTION__) == sizeof(__FUNCTION__)) { + static_assert(always_false_v, "magic_enum::detail::n requires __PRETTY_FUNCTION__."); + return str_view{}; + } else if (name.str_[name.size_ - 1] == ']') { + name.size_ -= 55; + name.str_ += 54; + } else { + name.size_ -= 40; + name.str_ += 37; + } + if (name.str_[0] == '(') { + name = str_view{}; + } #elif defined(_MSC_VER) - str_view name; - if ((__FUNCSIG__[5] == '_' && __FUNCSIG__[35] != '(') || - (__FUNCSIG__[5] == 'c' && __FUNCSIG__[41] != '(')) - { - // CLI/C++ workaround (see - // https://github.com/Neargye/magic_enum/issues/284). - name.str_ = __FUNCSIG__; - name.str_ += 35; - name.size_ = sizeof(__FUNCSIG__) - 52; - } + str_view name; + if ((__FUNCSIG__[5] == '_' && __FUNCSIG__[35] != '(') || (__FUNCSIG__[5] == 'c' && __FUNCSIG__[41] != '(')) { + // CLI/C++ workaround (see https://github.com/Neargye/magic_enum/issues/284). + name.str_ = __FUNCSIG__; + name.str_ += 35; + name.size_ = sizeof(__FUNCSIG__) - 52; + } #else - auto name = str_view{}; + auto name = str_view{}; #endif - std::size_t p = 0; - for (std::size_t i = name.size_; i > 0; --i) - { - if (name.str_[i] == ':') - { - p = i + 1; - break; - } - } - if (p > 0) - { - name.size_ -= p; - name.str_ += p; - } - return name; + std::size_t p = 0; + for (std::size_t i = name.size_; i > 0; --i) { + if (name.str_[i] == ':') { + p = i + 1; + break; + } } - else - { - return str_view{}; // Unsupported compiler or Invalid customize. + if (p > 0) { + name.size_ -= p; + name.str_ += p; } + return name; + } else { + return str_view{}; // Unsupported compiler or Invalid customize. + } } #if defined(_MSC_VER) && !defined(__clang__) && _MSC_VER < 1920 -#define MAGIC_ENUM_VS_2017_WORKAROUND 1 +# define MAGIC_ENUM_VS_2017_WORKAROUND 1 #endif #if defined(MAGIC_ENUM_VS_2017_WORKAROUND) template -constexpr auto -n() noexcept -{ - static_assert(is_enum_v, "magic_enum::detail::n requires enum type."); +constexpr auto n() noexcept { + static_assert(is_enum_v, "magic_enum::detail::n requires enum type."); -#if defined(MAGIC_ENUM_GET_ENUM_NAME_BUILTIN) - constexpr auto name_ptr = MAGIC_ENUM_GET_ENUM_NAME_BUILTIN(V); - auto name = name_ptr - ? str_view{name_ptr, std::char_traits::length(name_ptr)} - : str_view{}; -#else - // CLI/C++ workaround (see - // https://github.com/Neargye/magic_enum/issues/284). - str_view name; - name.str_ = __FUNCSIG__; - name.size_ = sizeof(__FUNCSIG__) - 17; - std::size_t p = 0; - for (std::size_t i = name.size_; i > 0; --i) - { - if (name.str_[i] == ',' || name.str_[i] == ':') - { - p = i + 1; - break; - } +# if defined(MAGIC_ENUM_GET_ENUM_NAME_BUILTIN) + constexpr auto name_ptr = MAGIC_ENUM_GET_ENUM_NAME_BUILTIN(V); + auto name = name_ptr ? str_view{name_ptr, std::char_traits::length(name_ptr)} : str_view{}; +# else + // CLI/C++ workaround (see https://github.com/Neargye/magic_enum/issues/284). + str_view name; + name.str_ = __FUNCSIG__; + name.size_ = sizeof(__FUNCSIG__) - 17; + std::size_t p = 0; + for (std::size_t i = name.size_; i > 0; --i) { + if (name.str_[i] == ',' || name.str_[i] == ':') { + p = i + 1; + break; } - if (p > 0) - { - name.size_ -= p; - name.str_ += p; - } - if (name.str_[0] == '(' || name.str_[0] == '-' || - (name.str_[0] >= '0' && name.str_[0] <= '9')) - { - name = str_view{}; - } - return name; -#endif + } + if (p > 0) { + name.size_ -= p; + name.str_ += p; + } + if (name.str_[0] == '(' || name.str_[0] == '-' || (name.str_[0] >= '0' && name.str_[0] <= '9')) { + name = str_view{}; + } + return name; +# endif } #endif template -constexpr auto -enum_name() noexcept -{ - [[maybe_unused]] constexpr auto custom = customize::enum_name(V); - static_assert( - std::is_same_v, customize::customize_t>, - "magic_enum::customize requires customize_t type."); - if constexpr (custom.first == customize::detail::customize_tag::custom_tag) - { - constexpr auto name = custom.second; - static_assert( - !name.empty(), "magic_enum::customize requires not empty string."); - return static_str{name}; - } - else if constexpr ( - custom.first == customize::detail::customize_tag::invalid_tag) - { - return static_str<0>{}; - } - else if constexpr ( - custom.first == customize::detail::customize_tag::default_tag) - { +constexpr auto enum_name() noexcept { + [[maybe_unused]] constexpr auto custom = customize::enum_name(V); + static_assert(std::is_same_v, customize::customize_t>, "magic_enum::customize requires customize_t type."); + if constexpr (custom.first == customize::detail::customize_tag::custom_tag) { + constexpr auto name = custom.second; + static_assert(!name.empty(), "magic_enum::customize requires not empty string."); + return static_str{name}; + } else if constexpr (custom.first == customize::detail::customize_tag::invalid_tag) { + return static_str<0>{}; + } else if constexpr (custom.first == customize::detail::customize_tag::default_tag) { #if defined(MAGIC_ENUM_VS_2017_WORKAROUND) - constexpr auto name = n(); + constexpr auto name = n(); #else - constexpr auto name = n(); + constexpr auto name = n(); #endif - return static_str{name}; - } - else - { - static_assert(always_false_v, "magic_enum::customize invalid."); - } + return static_str{name}; + } else { + static_assert(always_false_v, "magic_enum::customize invalid."); + } } template inline constexpr auto enum_name_v = enum_name(); template -constexpr bool -is_valid() noexcept -{ +constexpr bool is_valid() noexcept { #if defined(__clang__) && __clang_major__ >= 16 - // https://reviews.llvm.org/D130058, https://reviews.llvm.org/D131307 - constexpr E v = __builtin_bit_cast(E, V); + // https://reviews.llvm.org/D130058, https://reviews.llvm.org/D131307 + constexpr E v = __builtin_bit_cast(E, V); #else - constexpr E v = static_cast(V); + constexpr E v = static_cast(V); #endif - [[maybe_unused]] constexpr auto custom = customize::enum_name(v); - static_assert( - std::is_same_v, customize::customize_t>, - "magic_enum::customize requires customize_t type."); - if constexpr (custom.first == customize::detail::customize_tag::custom_tag) - { - constexpr auto name = custom.second; - static_assert( - !name.empty(), "magic_enum::customize requires not empty string."); - return name.size() != 0; - } - else if constexpr ( - custom.first == customize::detail::customize_tag::default_tag) - { + [[maybe_unused]] constexpr auto custom = customize::enum_name(v); + static_assert(std::is_same_v, customize::customize_t>, "magic_enum::customize requires customize_t type."); + if constexpr (custom.first == customize::detail::customize_tag::custom_tag) { + constexpr auto name = custom.second; + static_assert(!name.empty(), "magic_enum::customize requires not empty string."); + return name.size() != 0; + } else if constexpr (custom.first == customize::detail::customize_tag::default_tag) { #if defined(MAGIC_ENUM_VS_2017_WORKAROUND) - return n().size_ != 0; + return n().size_ != 0; #else - return n().size_ != 0; + return n().size_ != 0; #endif - } - else - { - return false; - } + } else { + return false; + } } -enum class enum_subtype { common, flags }; +enum class enum_subtype { + common, + flags +}; -template < - typename E, - int O, - enum_subtype S, - typename U = std::underlying_type_t> -constexpr U -ualue(std::size_t i) noexcept -{ - if constexpr (std::is_same_v) - { // bool special case - static_assert( - O == 0, "magic_enum::detail::ualue requires valid offset."); +template > +constexpr U ualue(std::size_t i) noexcept { + if constexpr (std::is_same_v) { // bool special case + static_assert(O == 0, "magic_enum::detail::ualue requires valid offset."); - return static_cast(i); - } - else if constexpr (S == enum_subtype::flags) - { - return static_cast(U{1} << static_cast(static_cast(i) + O)); - } - else - { - return static_cast(static_cast(i) + O); - } + return static_cast(i); + } else if constexpr (S == enum_subtype::flags) { + return static_cast(U{1} << static_cast(static_cast(i) + O)); + } else { + return static_cast(static_cast(i) + O); + } } -template < - typename E, - int O, - enum_subtype S, - typename U = std::underlying_type_t> -constexpr E -value(std::size_t i) noexcept -{ - return static_cast(ualue(i)); +template > +constexpr E value(std::size_t i) noexcept { + return static_cast(ualue(i)); } template > -constexpr int -reflected_min() noexcept -{ - if constexpr (S == enum_subtype::flags) - { - return 0; - } - else - { - constexpr auto lhs = range_min::value; - constexpr auto rhs = (std::numeric_limits::min)(); +constexpr int reflected_min() noexcept { + if constexpr (S == enum_subtype::flags) { + return 0; + } else { + constexpr auto lhs = range_min::value; + constexpr auto rhs = (std::numeric_limits::min)(); - if constexpr (cmp_less(rhs, lhs)) - { - return lhs; - } - else - { - return rhs; - } + if constexpr (cmp_less(rhs, lhs)) { + return lhs; + } else { + return rhs; } + } } template > -constexpr int -reflected_max() noexcept -{ - if constexpr (S == enum_subtype::flags) - { - return std::numeric_limits::digits - 1; - } - else - { - constexpr auto lhs = range_max::value; - constexpr auto rhs = (std::numeric_limits::max)(); +constexpr int reflected_max() noexcept { + if constexpr (S == enum_subtype::flags) { + return std::numeric_limits::digits - 1; + } else { + constexpr auto lhs = range_max::value; + constexpr auto rhs = (std::numeric_limits::max)(); - if constexpr (cmp_less(lhs, rhs)) - { - return lhs; - } - else - { - return rhs; - } + if constexpr (cmp_less(lhs, rhs)) { + return lhs; + } else { + return rhs; } + } } -#define MAGIC_ENUM_FOR_EACH_256(T) \ - T(0) \ - T(1) T(2) T(3) T(4) T(5) T(6) T(7) T(8) T(9) T(10) T(11) T(12) T(13) T(14) \ - T(15) T(16) T(17) T(18) T(19) T(20) T(21) T(22) T(23) T(24) T(25) T( \ - 26) T(27) T(28) T(29) T(30) T(31) T(32) T(33) T(34) T(35) T(36) \ - T(37) T(38) T(39) T(40) T(41) T(42) T(43) T(44) T(45) T(46) T(47) \ - T(48) T(49) T(50) T(51) T(52) T(53) T(54) T(55) T(56) T(57) \ - T(58) T(59) T(60) T(61) T(62) T(63) T(64) T(65) T(66) \ - T(67) T(68) T(69) T(70) T(71) T(72) T(73) T(74) T(75) \ - T(76) T(77) T(78) T(79) T(80) T(81) T(82) T(83) \ - T(84) T(85) T(86) T(87) T(88) T(89) T(90) T( \ - 91) T(92) T(93) \ - T(94) T( \ - 95) T(96) T(97) \ - T(98) T( \ - 99) T(100) T(101) T(102) \ - T(103) T(104) T(105) T( \ - 106) T(107) T(108) T(109) T(110) \ - T(111) T(112) T(113) T( \ - 114) T(115) T(116) T(117) \ - T(118) T(119) T(120) T(121) T(122) T(123) T( \ - 124) T(125) T(126) T(127) T(128) \ - T(129) T(130) T(131) T( \ - 132) T(133) T(134) T(135) T(136) \ - T(137) T(138) T(139) T( \ - 140) T(141) T(142) T(143) T(144) \ - T(145) T(146) T(147) T( \ - 148) T(149) T(150) T(151) T(152) \ - T(153) T(154) T(155) T( \ - 156) T(157) T(158) T(159) \ - T(160) T(161) T(162) T( \ - 163) T(164) T(165) \ - T(166) T(167) T(168) T( \ - 169) T(170) T(171) \ - T(172) T(173) T( \ - 174) T(175) \ - T(176) T( \ - 177) T(178) \ - T(179) T( \ - 180) \ - T(181) T(182) T(183) T(184) T(185) T(186) T(187) T(188) T(189) T(190) T(191) T(192) T(193) T(194) T(195) T(196) T(197) T(198) T(199) T(200) T(201) T(202) T(203) T(204) T(205) T(206) T(207) T(208) T(209) T(210) T(211) T(212) T(213) T(214) T(215) T(216) T(217) T(218) T(219) T(220) T(221) T(222) T(223) T(224) T(225) T(226) T( \ - 227) T(228) \ - T(229) T( \ - 230) \ - T( \ - 231) T(232) T(233) T(234) T(235) T(236) T(237) T(238) T(239) T(240) T(241) T(242) T(243) T(244) T(245) T(246) T(247) T(248) T(249) T(250) T(251) T(252) \ - T(253) T( \ - 254) \ - T(255) +#define MAGIC_ENUM_FOR_EACH_256(T) \ + T( 0)T( 1)T( 2)T( 3)T( 4)T( 5)T( 6)T( 7)T( 8)T( 9)T( 10)T( 11)T( 12)T( 13)T( 14)T( 15)T( 16)T( 17)T( 18)T( 19)T( 20)T( 21)T( 22)T( 23)T( 24)T( 25)T( 26)T( 27)T( 28)T( 29)T( 30)T( 31) \ + T( 32)T( 33)T( 34)T( 35)T( 36)T( 37)T( 38)T( 39)T( 40)T( 41)T( 42)T( 43)T( 44)T( 45)T( 46)T( 47)T( 48)T( 49)T( 50)T( 51)T( 52)T( 53)T( 54)T( 55)T( 56)T( 57)T( 58)T( 59)T( 60)T( 61)T( 62)T( 63) \ + T( 64)T( 65)T( 66)T( 67)T( 68)T( 69)T( 70)T( 71)T( 72)T( 73)T( 74)T( 75)T( 76)T( 77)T( 78)T( 79)T( 80)T( 81)T( 82)T( 83)T( 84)T( 85)T( 86)T( 87)T( 88)T( 89)T( 90)T( 91)T( 92)T( 93)T( 94)T( 95) \ + T( 96)T( 97)T( 98)T( 99)T(100)T(101)T(102)T(103)T(104)T(105)T(106)T(107)T(108)T(109)T(110)T(111)T(112)T(113)T(114)T(115)T(116)T(117)T(118)T(119)T(120)T(121)T(122)T(123)T(124)T(125)T(126)T(127) \ + T(128)T(129)T(130)T(131)T(132)T(133)T(134)T(135)T(136)T(137)T(138)T(139)T(140)T(141)T(142)T(143)T(144)T(145)T(146)T(147)T(148)T(149)T(150)T(151)T(152)T(153)T(154)T(155)T(156)T(157)T(158)T(159) \ + T(160)T(161)T(162)T(163)T(164)T(165)T(166)T(167)T(168)T(169)T(170)T(171)T(172)T(173)T(174)T(175)T(176)T(177)T(178)T(179)T(180)T(181)T(182)T(183)T(184)T(185)T(186)T(187)T(188)T(189)T(190)T(191) \ + T(192)T(193)T(194)T(195)T(196)T(197)T(198)T(199)T(200)T(201)T(202)T(203)T(204)T(205)T(206)T(207)T(208)T(209)T(210)T(211)T(212)T(213)T(214)T(215)T(216)T(217)T(218)T(219)T(220)T(221)T(222)T(223) \ + T(224)T(225)T(226)T(227)T(228)T(229)T(230)T(231)T(232)T(233)T(234)T(235)T(236)T(237)T(238)T(239)T(240)T(241)T(242)T(243)T(244)T(245)T(246)T(247)T(248)T(249)T(250)T(251)T(252)T(253)T(254)T(255) template -constexpr void -valid_count(bool* valid, std::size_t& count) noexcept -{ -#define MAGIC_ENUM_V(O) \ - if constexpr ((I + O) < Size) \ - { \ - if constexpr (is_valid(I + O)>()) \ - { \ - valid[I + O] = true; \ - ++count; \ - } \ - } +constexpr void valid_count(bool* valid, std::size_t& count) noexcept { +#define MAGIC_ENUM_V(O) \ + if constexpr ((I + O) < Size) { \ + if constexpr (is_valid(I + O)>()) { \ + valid[I + O] = true; \ + ++count; \ + } \ + } - MAGIC_ENUM_FOR_EACH_256(MAGIC_ENUM_V) + MAGIC_ENUM_FOR_EACH_256(MAGIC_ENUM_V) - if constexpr ((I + 256) < Size) - { - valid_count(valid, count); - } + if constexpr ((I + 256) < Size) { + valid_count(valid, count); + } #undef MAGIC_ENUM_V } template -struct valid_count_t -{ - std::size_t count = 0; - bool valid[N] = {}; +struct valid_count_t { + std::size_t count = 0; + bool valid[N] = {}; }; template -constexpr auto -valid_count() noexcept -{ - valid_count_t vc; - valid_count(vc.valid, vc.count); - return vc; +constexpr auto valid_count() noexcept { + valid_count_t vc; + valid_count(vc.valid, vc.count); + return vc; } template -constexpr auto -values() noexcept -{ - constexpr auto vc = valid_count(); +constexpr auto values() noexcept { + constexpr auto vc = valid_count(); - if constexpr (vc.count > 0) - { + if constexpr (vc.count > 0) { #if defined(MAGIC_ENUM_ARRAY_CONSTEXPR) - std::array values = {}; + std::array values = {}; #else - E values[vc.count] = {}; + E values[vc.count] = {}; #endif - for (std::size_t i = 0, v = 0; v < vc.count; ++i) - { - if (vc.valid[i]) - { - values[v++] = value(i); - } - } + for (std::size_t i = 0, v = 0; v < vc.count; ++i) { + if (vc.valid[i]) { + values[v++] = value(i); + } + } #if defined(MAGIC_ENUM_ARRAY_CONSTEXPR) - return values; + return values; #else - return to_array(values, std::make_index_sequence{}); + return to_array(values, std::make_index_sequence{}); #endif - } - else - { - return std::array{}; - } + } else { + return std::array{}; + } } template > -constexpr auto -values() noexcept -{ - constexpr auto min = reflected_min(); - constexpr auto max = reflected_max(); - constexpr auto range_size = max - min + 1; - static_assert( - range_size > 0, "magic_enum::enum_range requires valid size."); +constexpr auto values() noexcept { + constexpr auto min = reflected_min(); + constexpr auto max = reflected_max(); + constexpr auto range_size = max - min + 1; + static_assert(range_size > 0, "magic_enum::enum_range requires valid size."); - return values(); + return values(); } template > -constexpr enum_subtype subtype(std::true_type) noexcept -{ - if constexpr (std::is_same_v) - { // bool special case - return enum_subtype::common; - } - else if constexpr (has_is_flags::value) - { - return customize::enum_range::is_flags ? enum_subtype::flags - : enum_subtype::common; - } - else - { +constexpr enum_subtype subtype(std::true_type) noexcept { + if constexpr (std::is_same_v) { // bool special case + return enum_subtype::common; + } else if constexpr (has_is_flags::value) { + return customize::enum_range::is_flags ? enum_subtype::flags : enum_subtype::common; + } else { #if defined(MAGIC_ENUM_AUTO_IS_FLAGS) - constexpr auto flags_values = values(); - constexpr auto default_values = values(); - if (flags_values.size() == 0 || - default_values.size() > flags_values.size()) - { - return enum_subtype::common; - } - for (std::size_t i = 0; i < default_values.size(); ++i) - { - const auto v = static_cast(default_values[i]); - if (v != 0 && (v & (v - 1)) != 0) - { - return enum_subtype::common; - } - } - return enum_subtype::flags; -#else - return enum_subtype::common; -#endif + constexpr auto flags_values = values(); + constexpr auto default_values = values(); + if (flags_values.size() == 0 || default_values.size() > flags_values.size()) { + return enum_subtype::common; } + for (std::size_t i = 0; i < default_values.size(); ++i) { + const auto v = static_cast(default_values[i]); + if (v != 0 && (v & (v - 1)) != 0) { + return enum_subtype::common; + } + } + return enum_subtype::flags; +#else + return enum_subtype::common; +#endif + } } template -constexpr enum_subtype subtype(std::false_type) noexcept -{ - // For non-enum type return default common subtype. - return enum_subtype::common; +constexpr enum_subtype subtype(std::false_type) noexcept { + // For non-enum type return default common subtype. + return enum_subtype::common; } template > @@ -1224,68 +818,48 @@ template inline constexpr auto count_v = values_v.size(); template > -inline constexpr auto min_v = (count_v > 0) - ? static_cast(values_v.front()) - : U{0}; +inline constexpr auto min_v = (count_v > 0) ? static_cast(values_v.front()) : U{0}; template > -inline constexpr auto max_v = (count_v > 0) - ? static_cast(values_v.back()) - : U{0}; +inline constexpr auto max_v = (count_v > 0) ? static_cast(values_v.back()) : U{0}; template -constexpr auto names(std::index_sequence) noexcept -{ - constexpr auto names = std::array{ - {enum_name_v[I]>...}}; - return names; +constexpr auto names(std::index_sequence) noexcept { + constexpr auto names = std::array{{enum_name_v[I]>...}}; + return names; } template -inline constexpr auto names_v = - names(std::make_index_sequence>{}); +inline constexpr auto names_v = names(std::make_index_sequence>{}); template > using names_t = decltype((names_v)); template -constexpr auto entries(std::index_sequence) noexcept -{ - constexpr auto entries = - std::array, sizeof...(I)>{ - {{values_v[I], enum_name_v[I]>}...}}; - return entries; +constexpr auto entries(std::index_sequence) noexcept { + constexpr auto entries = std::array, sizeof...(I)>{{{values_v[I], enum_name_v[I]>}...}}; + return entries; } template -inline constexpr auto entries_v = - entries(std::make_index_sequence>{}); +inline constexpr auto entries_v = entries(std::make_index_sequence>{}); template > using entries_t = decltype((entries_v)); template > -constexpr bool -is_sparse() noexcept -{ - if constexpr (count_v == 0) - { - return false; - } - else if constexpr (std::is_same_v) - { // bool special case - return false; - } - else - { - constexpr auto max = - (S == enum_subtype::flags) ? log2(max_v) : max_v; - constexpr auto min = - (S == enum_subtype::flags) ? log2(min_v) : min_v; - constexpr auto range_size = max - min + 1; +constexpr bool is_sparse() noexcept { + if constexpr (count_v == 0) { + return false; + } else if constexpr (std::is_same_v) { // bool special case + return false; + } else { + constexpr auto max = (S == enum_subtype::flags) ? log2(max_v) : max_v; + constexpr auto min = (S == enum_subtype::flags) ? log2(min_v) : min_v; + constexpr auto range_size = max - min + 1; - return range_size != count_v; - } + return range_size != count_v; + } } template > @@ -1294,79 +868,46 @@ inline constexpr bool is_sparse_v = is_sparse(); template struct is_reflected #if defined(MAGIC_ENUM_NO_CHECK_REFLECTED_ENUM) - : std::true_type -{ -}; + : std::true_type {}; #else - : std::bool_constant && (count_v != 0)> -{ -}; + : std::bool_constant && (count_v != 0)> {}; #endif template inline constexpr bool is_reflected_v = is_reflected, S>{}; template -struct enable_if_enum -{ -}; +struct enable_if_enum {}; template -struct enable_if_enum -{ - using type = R; - static_assert( - supported::value, - "magic_enum unsupported compiler " - "(https://github.com/Neargye/magic_enum#compiler-compatibility)."); +struct enable_if_enum { + using type = R; + static_assert(supported::value, "magic_enum unsupported compiler (https://github.com/Neargye/magic_enum#compiler-compatibility)."); }; -template < - typename T, - typename R, - typename BinaryPredicate = std::equal_to<>, - typename D = std::decay_t> -using enable_if_t = typename enable_if_enum< - std::is_enum_v && - std::is_invocable_r_v, - R>::type; +template , typename D = std::decay_t> +using enable_if_t = typename enable_if_enum && std::is_invocable_r_v, R>::type; -template < - typename T, - std::enable_if_t>, int> = 0> +template >, int> = 0> using enum_concept = T; template > -struct is_scoped_enum : std::false_type -{ -}; +struct is_scoped_enum : std::false_type {}; template -struct is_scoped_enum - : std::bool_constant>> -{ -}; +struct is_scoped_enum : std::bool_constant>> {}; template > -struct is_unscoped_enum : std::false_type -{ -}; +struct is_unscoped_enum : std::false_type {}; template -struct is_unscoped_enum - : std::bool_constant>> -{ -}; +struct is_unscoped_enum : std::bool_constant>> {}; template >> -struct underlying_type -{ -}; +struct underlying_type {}; template -struct underlying_type : std::underlying_type> -{ -}; +struct underlying_type : std::underlying_type> {}; #if defined(MAGIC_ENUM_ENABLE_HASH) || defined(MAGIC_ENUM_ENABLE_HASH_SWITCH) @@ -1374,330 +915,212 @@ template struct constexpr_hash_t; template -struct constexpr_hash_t>> -{ - constexpr auto - operator()(Value value) const noexcept - { - using U = typename underlying_type::type; - if constexpr (std::is_same_v) - { // bool special case - return static_cast(value); - } - else - { - return static_cast(value); - } +struct constexpr_hash_t>> { + constexpr auto operator()(Value value) const noexcept { + using U = typename underlying_type::type; + if constexpr (std::is_same_v) { // bool special case + return static_cast(value); + } else { + return static_cast(value); } - using secondary_hash = constexpr_hash_t; + } + using secondary_hash = constexpr_hash_t; }; template -struct constexpr_hash_t< - Value, - std::enable_if_t>> -{ - static constexpr std::uint32_t crc_table[256]{ - 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, - 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, - 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, - 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, - 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, - 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, - 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, - 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, - 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, - 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, - 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, - 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, - 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, - 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, - 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, - 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, - 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, - 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, - 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, - 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, - 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, - 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, - 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, - 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, - 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, - 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, - 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, - 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, - 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, - 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, - 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, - 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, - 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, - 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, - 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, - 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, - 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, - 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, - 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, - 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, - 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, - 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, - 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, - 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, - 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, - 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, - 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, - 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, - 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, - 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, - 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, - 0x2d02ef8dL}; - constexpr std::uint32_t - operator()(string_view value) const noexcept - { - auto crc = static_cast(0xffffffffL); - for (const auto c : value) - { - crc = (crc >> 8) ^ - crc_table[(crc ^ static_cast(c)) & 0xff]; - } - return crc ^ 0xffffffffL; +struct constexpr_hash_t>> { + static constexpr std::uint32_t crc_table[256] { + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, + 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L, + 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, + 0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L, + 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, + 0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL, + 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, + 0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L, + 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, + 0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L, + 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, + 0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L, + 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, + 0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L, + 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, + 0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L, + 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, + 0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L, + 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, + 0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL, + 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, + 0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L, + 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, + 0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL, + 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, + 0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL + }; + constexpr std::uint32_t operator()(string_view value) const noexcept { + auto crc = static_cast(0xffffffffL); + for (const auto c : value) { + crc = (crc >> 8) ^ crc_table[(crc ^ static_cast(c)) & 0xff]; } + return crc ^ 0xffffffffL; + } - struct secondary_hash - { - constexpr std::uint32_t - operator()(string_view value) const noexcept - { - auto acc = static_cast(2166136261ULL); - for (const auto c : value) - { - acc = ((acc ^ static_cast(c)) * - static_cast(16777619ULL)) & - (std::numeric_limits::max)(); - } - return static_cast(acc); - } - }; + struct secondary_hash { + constexpr std::uint32_t operator()(string_view value) const noexcept { + auto acc = static_cast(2166136261ULL); + for (const auto c : value) { + acc = ((acc ^ static_cast(c)) * static_cast(16777619ULL)) & (std::numeric_limits::max)(); + } + return static_cast(acc); + } + }; }; template inline constexpr Hash hash_v{}; template -constexpr auto -calculate_cases(std::size_t Page) noexcept -{ - constexpr std::array values = *GlobValues; - constexpr std::size_t size = values.size(); +constexpr auto calculate_cases(std::size_t Page) noexcept { + constexpr std::array values = *GlobValues; + constexpr std::size_t size = values.size(); - using switch_t = - std::invoke_result_t; - static_assert( - std::is_integral_v && !std::is_same_v); - const std::size_t values_to = - (std::min)(static_cast(256), size - Page); + using switch_t = std::invoke_result_t; + static_assert(std::is_integral_v && !std::is_same_v); + const std::size_t values_to = (std::min)(static_cast(256), size - Page); - std::array result{}; - auto fill = result.begin(); - { - auto first = values.begin() + static_cast(Page); - auto last = - values.begin() + static_cast(Page + values_to); - while (first != last) - { - *fill++ = hash_v(*first++); - } + std::array result{}; + auto fill = result.begin(); + { + auto first = values.begin() + static_cast(Page); + auto last = values.begin() + static_cast(Page + values_to); + while (first != last) { + *fill++ = hash_v(*first++); } + } - // dead cases, try to avoid case collisions - for (switch_t last_value = result[values_to - 1]; fill != result.end() && - last_value != (std::numeric_limits::max)(); - *fill++ = ++last_value) - { + // dead cases, try to avoid case collisions + for (switch_t last_value = result[values_to - 1]; fill != result.end() && last_value != (std::numeric_limits::max)(); *fill++ = ++last_value) { + } + + { + auto it = result.begin(); + auto last_value = (std::numeric_limits::min)(); + for (; fill != result.end(); *fill++ = last_value++) { + while (last_value == *it) { + ++last_value, ++it; + } } + } - { - auto it = result.begin(); - auto last_value = (std::numeric_limits::min)(); - for (; fill != result.end(); *fill++ = last_value++) - { - while (last_value == *it) - { - ++last_value, ++it; - } - } - } - - return result; + return result; } template -constexpr R -invoke_r(F&& f, Args&&... args) noexcept( - std::is_nothrow_invocable_r_v) -{ - if constexpr (std::is_void_v) - { - std::forward(f)(std::forward(args)...); - } - else - { - return static_cast(std::forward(f)(std::forward(args)...)); - } +constexpr R invoke_r(F&& f, Args&&... args) noexcept(std::is_nothrow_invocable_r_v) { + if constexpr (std::is_void_v) { + std::forward(f)(std::forward(args)...); + } else { + return static_cast(std::forward(f)(std::forward(args)...)); + } } -enum class case_call_t { index, value }; +enum class case_call_t { + index, + value +}; template -inline constexpr auto default_result_type_lambda = - []() noexcept(std::is_nothrow_default_constructible_v) { return T{}; }; +inline constexpr auto default_result_type_lambda = []() noexcept(std::is_nothrow_default_constructible_v) { return T{}; }; template <> inline constexpr auto default_result_type_lambda = []() noexcept {}; template -constexpr bool -has_duplicate() noexcept -{ - using value_t = std::decay_t; - using hash_value_t = std::invoke_result_t; - std::arraysize()> hashes{}; - std::size_t size = 0; - for (auto elem : *Arr) - { - hashes[size] = hash_v(elem); - for (auto i = size++; i > 0; --i) - { - if (hashes[i] < hashes[i - 1]) - { - auto tmp = hashes[i]; - hashes[i] = hashes[i - 1]; - hashes[i - 1] = tmp; - } - else if (hashes[i] == hashes[i - 1]) - { - return false; - } - else - { - break; - } - } +constexpr bool has_duplicate() noexcept { + using value_t = std::decay_t; + using hash_value_t = std::invoke_result_t; + std::arraysize()> hashes{}; + std::size_t size = 0; + for (auto elem : *Arr) { + hashes[size] = hash_v(elem); + for (auto i = size++; i > 0; --i) { + if (hashes[i] < hashes[i - 1]) { + auto tmp = hashes[i]; + hashes[i] = hashes[i - 1]; + hashes[i - 1] = tmp; + } else if (hashes[i] == hashes[i - 1]) { + return false; + } else { + break; + } } - return true; + } + return true; } -#define MAGIC_ENUM_CASE(val) \ - case cases[val]: \ - if constexpr ((val) + Page < size) \ - { \ - if (!pred(values[val + Page], searched)) \ - { \ - break; \ - } \ - if constexpr (CallValue == case_call_t::index) \ - { \ - if constexpr ( \ - std::is_invocable_r_v< \ - result_t, \ - Lambda, \ - std::integral_constant>) \ - { \ - return detail::invoke_r( \ - std::forward(lambda), \ - std::integral_constant{}); \ - } \ - else if constexpr ( \ - std::is_invocable_v< \ - Lambda, \ - std::integral_constant>) \ - { \ - MAGIC_ENUM_ASSERT( \ - false && \ - "magic_enum::detail::constexpr_switch wrong result " \ - "type."); \ - } \ - } \ - else if constexpr (CallValue == case_call_t::value) \ - { \ - if constexpr (std::is_invocable_r_v< \ - result_t, \ - Lambda, \ - enum_constant>) \ - { \ - return detail::invoke_r( \ - std::forward(lambda), \ - enum_constant{}); \ - } \ - else if constexpr (std::is_invocable_r_v< \ - result_t, \ - Lambda, \ - enum_constant>) \ - { \ - MAGIC_ENUM_ASSERT( \ - false && \ - "magic_enum::detail::constexpr_switch wrong result " \ - "type."); \ - } \ - } \ - break; \ - } \ - else \ - [[fallthrough]]; +#define MAGIC_ENUM_CASE(val) \ + case cases[val]: \ + if constexpr ((val) + Page < size) { \ + if (!pred(values[val + Page], searched)) { \ + break; \ + } \ + if constexpr (CallValue == case_call_t::index) { \ + if constexpr (std::is_invocable_r_v>) { \ + return detail::invoke_r(std::forward(lambda), std::integral_constant{}); \ + } else if constexpr (std::is_invocable_v>) { \ + MAGIC_ENUM_ASSERT(false && "magic_enum::detail::constexpr_switch wrong result type."); \ + } \ + } else if constexpr (CallValue == case_call_t::value) { \ + if constexpr (std::is_invocable_r_v>) { \ + return detail::invoke_r(std::forward(lambda), enum_constant{}); \ + } else if constexpr (std::is_invocable_r_v>) { \ + MAGIC_ENUM_ASSERT(false && "magic_enum::detail::constexpr_switch wrong result type."); \ + } \ + } \ + break; \ + } else [[fallthrough]]; -template < - auto* GlobValues, - case_call_t CallValue, - std::size_t Page = 0, - typename Hash = constexpr_hash_t< - typename std::decay_t::value_type>, - typename BinaryPredicate = std::equal_to<>, - typename Lambda, - typename ResultGetterType> -constexpr decltype(auto) -constexpr_switch( +template ::value_type>, + typename BinaryPredicate = std::equal_to<>, + typename Lambda, + typename ResultGetterType> +constexpr decltype(auto) constexpr_switch( Lambda&& lambda, typename std::decay_t::value_type searched, ResultGetterType&& def, - BinaryPredicate&& pred = {}) -{ - using result_t = std::invoke_result_t; - using hash_t = std::conditional_t< - has_duplicate(), - Hash, - typename Hash::secondary_hash>; - static_assert( - has_duplicate(), - "magic_enum::detail::constexpr_switch duplicated hash found, please " - "report it: https://github.com/Neargye/magic_enum/issues."); - constexpr std::array values = *GlobValues; - constexpr std::size_t size = values.size(); - constexpr std::array cases = calculate_cases(Page); + BinaryPredicate&& pred = {}) { + using result_t = std::invoke_result_t; + using hash_t = std::conditional_t(), Hash, typename Hash::secondary_hash>; + static_assert(has_duplicate(), "magic_enum::detail::constexpr_switch duplicated hash found, please report it: https://github.com/Neargye/magic_enum/issues."); + constexpr std::array values = *GlobValues; + constexpr std::size_t size = values.size(); + constexpr std::array cases = calculate_cases(Page); - switch (hash_v(searched)) - { - MAGIC_ENUM_FOR_EACH_256(MAGIC_ENUM_CASE) - default: - if constexpr (size > 256 + Page) - { - return constexpr_switch< - GlobValues, - CallValue, - Page + 256, - Hash>( - std::forward(lambda), - searched, - std::forward(def)); - } - break; - } - return def(); + switch (hash_v(searched)) { + MAGIC_ENUM_FOR_EACH_256(MAGIC_ENUM_CASE) + default: + if constexpr (size > 256 + Page) { + return constexpr_switch(std::forward(lambda), searched, std::forward(def)); + } + break; + } + return def(); } #undef MAGIC_ENUM_CASE #endif -} // namespace detail +} // namespace magic_enum::detail // Checks is magic_enum supported compiler. inline constexpr bool is_magic_enum_supported = detail::supported::value; @@ -1706,38 +1129,25 @@ template using Enum = detail::enum_concept; // Checks whether T is an Unscoped enumeration type. -// Provides the member constant value which is equal to true, if T is an -// [Unscoped -// enumeration](https://en.cppreference.com/w/cpp/language/enum#Unscoped_enumeration) -// type. Otherwise, value is equal to false. +// Provides the member constant value which is equal to true, if T is an [Unscoped enumeration](https://en.cppreference.com/w/cpp/language/enum#Unscoped_enumeration) type. Otherwise, value is equal to false. template -struct is_unscoped_enum : detail::is_unscoped_enum -{ -}; +struct is_unscoped_enum : detail::is_unscoped_enum {}; template inline constexpr bool is_unscoped_enum_v = is_unscoped_enum::value; // Checks whether T is an Scoped enumeration type. -// Provides the member constant value which is equal to true, if T is an [Scoped -// enumeration](https://en.cppreference.com/w/cpp/language/enum#Scoped_enumerations) -// type. Otherwise, value is equal to false. +// Provides the member constant value which is equal to true, if T is an [Scoped enumeration](https://en.cppreference.com/w/cpp/language/enum#Scoped_enumerations) type. Otherwise, value is equal to false. template -struct is_scoped_enum : detail::is_scoped_enum -{ -}; +struct is_scoped_enum : detail::is_scoped_enum {}; template inline constexpr bool is_scoped_enum_v = is_scoped_enum::value; -// If T is a complete enumeration type, provides a member typedef type that -// names the underlying type of T. Otherwise, if T is not an enumeration type, -// there is no member type. Otherwise (T is an incomplete enumeration type), the -// program is ill-formed. +// If T is a complete enumeration type, provides a member typedef type that names the underlying type of T. +// Otherwise, if T is not an enumeration type, there is no member type. Otherwise (T is an incomplete enumeration type), the program is ill-formed. template -struct underlying_type : detail::underlying_type -{ -}; +struct underlying_type : detail::underlying_type {}; template using underlying_type_t = typename underlying_type::type; @@ -1747,464 +1157,312 @@ using enum_constant = detail::enum_constant; // Returns type name of enum. template -[[nodiscard]] constexpr auto -enum_type_name() noexcept -> detail::enable_if_t -{ - constexpr string_view name = detail::type_name_v>; - static_assert( - !name.empty(), - "magic_enum::enum_type_name enum type does not have a name."); +[[nodiscard]] constexpr auto enum_type_name() noexcept -> detail::enable_if_t { + constexpr string_view name = detail::type_name_v>; + static_assert(!name.empty(), "magic_enum::enum_type_name enum type does not have a name."); - return name; + return name; } // Returns number of enum values. template > -[[nodiscard]] constexpr auto -enum_count() noexcept -> detail::enable_if_t -{ - return detail::count_v, S>; +[[nodiscard]] constexpr auto enum_count() noexcept -> detail::enable_if_t { + return detail::count_v, S>; } // Returns enum value at specified index. -// No bounds checking is performed: the behavior is undefined if index >= number -// of enum values. +// No bounds checking is performed: the behavior is undefined if index >= number of enum values. template > -[[nodiscard]] constexpr auto -enum_value(std::size_t index) noexcept - -> detail::enable_if_t> -{ - using D = std::decay_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); +[[nodiscard]] constexpr auto enum_value(std::size_t index) noexcept -> detail::enable_if_t> { + using D = std::decay_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); - if constexpr (detail::is_sparse_v) - { - return MAGIC_ENUM_ASSERT(index < detail::count_v), - detail::values_v[index]; - } - else - { - constexpr auto min = (S == detail::enum_subtype::flags) - ? detail::log2(detail::min_v) - : detail::min_v; + if constexpr (detail::is_sparse_v) { + return MAGIC_ENUM_ASSERT(index < detail::count_v), detail::values_v[index]; + } else { + constexpr auto min = (S == detail::enum_subtype::flags) ? detail::log2(detail::min_v) : detail::min_v; - return MAGIC_ENUM_ASSERT(index < detail::count_v), - detail::value(index); - } + return MAGIC_ENUM_ASSERT(index < detail::count_v), detail::value(index); + } } // Returns enum value at specified index. -template < - typename E, - std::size_t I, - detail::enum_subtype S = detail::subtype_v> -[[nodiscard]] constexpr auto -enum_value() noexcept -> detail::enable_if_t> -{ - using D = std::decay_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); - static_assert( - I < detail::count_v, "magic_enum::enum_value out of range."); +template > +[[nodiscard]] constexpr auto enum_value() noexcept -> detail::enable_if_t> { + using D = std::decay_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); + static_assert(I < detail::count_v, "magic_enum::enum_value out of range."); - return enum_value(I); + return enum_value(I); } // Returns std::array with enum values, sorted by enum value. template > -[[nodiscard]] constexpr auto -enum_values() noexcept -> detail::enable_if_t> -{ - using D = std::decay_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); +[[nodiscard]] constexpr auto enum_values() noexcept -> detail::enable_if_t> { + using D = std::decay_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); - return detail::values_v; + return detail::values_v; } // Returns integer value from enum value. template -[[nodiscard]] constexpr auto -enum_integer(E value) noexcept -> detail::enable_if_t> -{ - return static_cast>(value); +[[nodiscard]] constexpr auto enum_integer(E value) noexcept -> detail::enable_if_t> { + return static_cast>(value); } // Returns underlying value from enum value. template -[[nodiscard]] constexpr auto -enum_underlying(E value) noexcept - -> detail::enable_if_t> -{ - return static_cast>(value); +[[nodiscard]] constexpr auto enum_underlying(E value) noexcept -> detail::enable_if_t> { + return static_cast>(value); } // Obtains index in enum values from enum value. // Returns optional with index. template > -[[nodiscard]] constexpr auto -enum_index(E value) noexcept -> detail::enable_if_t> -{ - using D = std::decay_t; - using U = underlying_type_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); +[[nodiscard]] constexpr auto enum_index(E value) noexcept -> detail::enable_if_t> { + using D = std::decay_t; + using U = underlying_type_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); - if constexpr ( - detail::is_sparse_v || (S == detail::enum_subtype::flags)) - { + if constexpr (detail::is_sparse_v || (S == detail::enum_subtype::flags)) { #if defined(MAGIC_ENUM_ENABLE_HASH) - return detail::constexpr_switch< - &detail::values_v, - detail::case_call_t::index>( - [](std::size_t i) { return optional{i}; }, - value, - detail::default_result_type_lambda>); + return detail::constexpr_switch<&detail::values_v, detail::case_call_t::index>( + [](std::size_t i) { return optional{i}; }, + value, + detail::default_result_type_lambda>); #else - for (std::size_t i = 0; i < detail::count_v; ++i) - { - if (enum_value(i) == value) - { - return i; - } - } - return {}; // Invalid value or out of range. + for (std::size_t i = 0; i < detail::count_v; ++i) { + if (enum_value(i) == value) { + return i; + } + } + return {}; // Invalid value or out of range. #endif + } else { + const auto v = static_cast(value); + if (v >= detail::min_v && v <= detail::max_v) { + return static_cast(v - detail::min_v); } - else - { - const auto v = static_cast(value); - if (v >= detail::min_v && v <= detail::max_v) - { - return static_cast(v - detail::min_v); - } - return {}; // Invalid value or out of range. - } + return {}; // Invalid value or out of range. + } } // Obtains index in enum values from enum value. // Returns optional with index. template -[[nodiscard]] constexpr auto -enum_index(E value) noexcept -> detail::enable_if_t> -{ - using D = std::decay_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); +[[nodiscard]] constexpr auto enum_index(E value) noexcept -> detail::enable_if_t> { + using D = std::decay_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); - return enum_index(value); + return enum_index(value); } // Obtains index in enum values from static storage enum variable. -template < - auto V, - detail::enum_subtype S = detail::subtype_v>> -[[nodiscard]] constexpr auto -enum_index() noexcept -> detail::enable_if_t -{ - using D = std::decay_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); - constexpr auto index = enum_index(V); - static_assert( - index, "magic_enum::enum_index enum value does not have a index."); +template >> +[[nodiscard]] constexpr auto enum_index() noexcept -> detail::enable_if_t {\ + using D = std::decay_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); + constexpr auto index = enum_index(V); + static_assert(index, "magic_enum::enum_index enum value does not have a index."); - return *index; + return *index; } // Returns name from static storage enum variable. -// This version is much lighter on the compile times and is not restricted to -// the enum_range limitation. +// This version is much lighter on the compile times and is not restricted to the enum_range limitation. template -[[nodiscard]] constexpr auto -enum_name() noexcept -> detail::enable_if_t -{ - constexpr string_view name = - detail::enum_name_v, V>; - static_assert( - !name.empty(), - "magic_enum::enum_name enum value does not have a name."); +[[nodiscard]] constexpr auto enum_name() noexcept -> detail::enable_if_t { + constexpr string_view name = detail::enum_name_v, V>; + static_assert(!name.empty(), "magic_enum::enum_name enum value does not have a name."); - return name; + return name; } // Returns name from enum value. // If enum value does not have name or value out of range, returns empty string. template > -[[nodiscard]] constexpr auto -enum_name(E value) noexcept -> detail::enable_if_t -{ - using D = std::decay_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); +[[nodiscard]] constexpr auto enum_name(E value) noexcept -> detail::enable_if_t { + using D = std::decay_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); - if (const auto i = enum_index(value)) - { - return detail::names_v[*i]; - } - return {}; + if (const auto i = enum_index(value)) { + return detail::names_v[*i]; + } + return {}; } // Returns name from enum value. // If enum value does not have name or value out of range, returns empty string. template -[[nodiscard]] constexpr auto -enum_name(E value) -> detail::enable_if_t -{ - using D = std::decay_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); +[[nodiscard]] constexpr auto enum_name(E value) -> detail::enable_if_t { + using D = std::decay_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); - return enum_name(value); + return enum_name(value); } // Returns std::array with names, sorted by enum value. template > -[[nodiscard]] constexpr auto -enum_names() noexcept -> detail::enable_if_t> -{ - using D = std::decay_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); +[[nodiscard]] constexpr auto enum_names() noexcept -> detail::enable_if_t> { + using D = std::decay_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); - return detail::names_v; + return detail::names_v; } // Returns std::array with pairs (value, name), sorted by enum value. template > -[[nodiscard]] constexpr auto -enum_entries() noexcept -> detail::enable_if_t> -{ - using D = std::decay_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); +[[nodiscard]] constexpr auto enum_entries() noexcept -> detail::enable_if_t> { + using D = std::decay_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); - return detail::entries_v; + return detail::entries_v; } -// Allows you to write magic_enum::enum_cast("bar", -// magic_enum::case_insensitive); +// Allows you to write magic_enum::enum_cast("bar", magic_enum::case_insensitive); inline constexpr auto case_insensitive = detail::case_insensitive<>{}; // Obtains enum value from integer value. // Returns optional with enum value. template > -[[nodiscard]] constexpr auto -enum_cast(underlying_type_t value) noexcept - -> detail::enable_if_t>> -{ - using D = std::decay_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); +[[nodiscard]] constexpr auto enum_cast(underlying_type_t value) noexcept -> detail::enable_if_t>> { + using D = std::decay_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); - if constexpr ( - detail::is_sparse_v || (S == detail::enum_subtype::flags)) - { + if constexpr (detail::is_sparse_v || (S == detail::enum_subtype::flags)) { #if defined(MAGIC_ENUM_ENABLE_HASH) - return detail::constexpr_switch< - &detail::values_v, - detail::case_call_t::value>( - [](D v) { return optional{v}; }, - static_cast(value), - detail::default_result_type_lambda>); + return detail::constexpr_switch<&detail::values_v, detail::case_call_t::value>( + [](D v) { return optional{v}; }, + static_cast(value), + detail::default_result_type_lambda>); #else - for (std::size_t i = 0; i < detail::count_v; ++i) - { - if (value == static_cast>(enum_value(i))) - { - return static_cast(value); - } - } - return {}; // Invalid value or out of range. + for (std::size_t i = 0; i < detail::count_v; ++i) { + if (value == static_cast>(enum_value(i))) { + return static_cast(value); + } + } + return {}; // Invalid value or out of range. #endif + } else { + if (value >= detail::min_v && value <= detail::max_v) { + return static_cast(value); } - else - { - if (value >= detail::min_v && value <= detail::max_v) - { - return static_cast(value); - } - return {}; // Invalid value or out of range. - } + return {}; // Invalid value or out of range. + } } // Obtains enum value from name. // Returns optional with enum value. -template < - typename E, - detail::enum_subtype S = detail::subtype_v, - typename BinaryPredicate = std::equal_to<>> -[[nodiscard]] constexpr auto -enum_cast(string_view value, [[maybe_unused]] BinaryPredicate p = {}) noexcept( - detail::is_nothrow_invocable()) - -> detail::enable_if_t>, BinaryPredicate> -{ - using D = std::decay_t; - static_assert( - detail::is_reflected_v, - "magic_enum requires enum implementation and valid max and min."); +template , typename BinaryPredicate = std::equal_to<>> +[[nodiscard]] constexpr auto enum_cast(string_view value, [[maybe_unused]] BinaryPredicate p = {}) noexcept(detail::is_nothrow_invocable()) -> detail::enable_if_t>, BinaryPredicate> { + using D = std::decay_t; + static_assert(detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min."); #if defined(MAGIC_ENUM_ENABLE_HASH) - if constexpr (detail::is_default_predicate()) - { - return detail::constexpr_switch< - &detail::names_v, - detail::case_call_t::index>( - [](std::size_t i) { - return optional{detail::values_v[i]}; - }, - value, - detail::default_result_type_lambda>, - [&p](string_view lhs, string_view rhs) { - return detail::cmp_equal(lhs, rhs, p); - }); - } + if constexpr (detail::is_default_predicate()) { + return detail::constexpr_switch<&detail::names_v, detail::case_call_t::index>( + [](std::size_t i) { return optional{detail::values_v[i]}; }, + value, + detail::default_result_type_lambda>, + [&p](string_view lhs, string_view rhs) { return detail::cmp_equal(lhs, rhs, p); }); + } #endif - for (std::size_t i = 0; i < detail::count_v; ++i) - { - if (detail::cmp_equal(value, detail::names_v[i], p)) - { - return enum_value(i); - } + for (std::size_t i = 0; i < detail::count_v; ++i) { + if (detail::cmp_equal(value, detail::names_v[i], p)) { + return enum_value(i); } - return {}; // Invalid value or out of range. + } + return {}; // Invalid value or out of range. } // Checks whether enum contains value with such value. template > -[[nodiscard]] constexpr auto -enum_contains(E value) noexcept -> detail::enable_if_t -{ - using D = std::decay_t; - using U = underlying_type_t; +[[nodiscard]] constexpr auto enum_contains(E value) noexcept -> detail::enable_if_t { + using D = std::decay_t; + using U = underlying_type_t; - return static_cast(enum_cast(static_cast(value))); + return static_cast(enum_cast(static_cast(value))); } // Checks whether enum contains value with such value. template -[[nodiscard]] constexpr auto -enum_contains(E value) noexcept -> detail::enable_if_t -{ - using D = std::decay_t; - using U = underlying_type_t; +[[nodiscard]] constexpr auto enum_contains(E value) noexcept -> detail::enable_if_t { + using D = std::decay_t; + using U = underlying_type_t; - return static_cast(enum_cast(static_cast(value))); + return static_cast(enum_cast(static_cast(value))); } // Checks whether enum contains value with such integer value. template > -[[nodiscard]] constexpr auto -enum_contains(underlying_type_t value) noexcept - -> detail::enable_if_t -{ - using D = std::decay_t; +[[nodiscard]] constexpr auto enum_contains(underlying_type_t value) noexcept -> detail::enable_if_t { + using D = std::decay_t; - return static_cast(enum_cast(value)); + return static_cast(enum_cast(value)); } // Checks whether enum contains enumerator with such name. -template < - typename E, - detail::enum_subtype S = detail::subtype_v, - typename BinaryPredicate = std::equal_to<>> -[[nodiscard]] constexpr auto -enum_contains(string_view value, BinaryPredicate p = {}) noexcept( - detail::is_nothrow_invocable()) - -> detail::enable_if_t -{ - using D = std::decay_t; +template , typename BinaryPredicate = std::equal_to<>> +[[nodiscard]] constexpr auto enum_contains(string_view value, BinaryPredicate p = {}) noexcept(detail::is_nothrow_invocable()) -> detail::enable_if_t { + using D = std::decay_t; - return static_cast(enum_cast(value, std::move(p))); + return static_cast(enum_cast(value, std::move(p))); } template -inline constexpr auto as_flags = - AsFlags ? detail::enum_subtype::flags : detail::enum_subtype::common; +inline constexpr auto as_flags = AsFlags ? detail::enum_subtype::flags : detail::enum_subtype::common; template -inline constexpr auto as_common = - AsFlags ? detail::enum_subtype::common : detail::enum_subtype::flags; +inline constexpr auto as_common = AsFlags ? detail::enum_subtype::common : detail::enum_subtype::flags; namespace bitwise_operators { template = 0> -constexpr E -operator~(E rhs) noexcept -{ - return static_cast(~static_cast>(rhs)); +constexpr E operator~(E rhs) noexcept { + return static_cast(~static_cast>(rhs)); } template = 0> -constexpr E -operator|(E lhs, E rhs) noexcept -{ - return static_cast( - static_cast>(lhs) | - static_cast>(rhs)); +constexpr E operator|(E lhs, E rhs) noexcept { + return static_cast(static_cast>(lhs) | static_cast>(rhs)); } template = 0> -constexpr E -operator&(E lhs, E rhs) noexcept -{ - return static_cast( - static_cast>(lhs) & - static_cast>(rhs)); +constexpr E operator&(E lhs, E rhs) noexcept { + return static_cast(static_cast>(lhs) & static_cast>(rhs)); } template = 0> -constexpr E -operator^(E lhs, E rhs) noexcept -{ - return static_cast( - static_cast>(lhs) ^ - static_cast>(rhs)); +constexpr E operator^(E lhs, E rhs) noexcept { + return static_cast(static_cast>(lhs) ^ static_cast>(rhs)); } template = 0> -constexpr E& -operator|=(E& lhs, E rhs) noexcept -{ - return lhs = (lhs | rhs); +constexpr E& operator|=(E& lhs, E rhs) noexcept { + return lhs = (lhs | rhs); } template = 0> -constexpr E& -operator&=(E& lhs, E rhs) noexcept -{ - return lhs = (lhs & rhs); +constexpr E& operator&=(E& lhs, E rhs) noexcept { + return lhs = (lhs & rhs); } template = 0> -constexpr E& -operator^=(E& lhs, E rhs) noexcept -{ - return lhs = (lhs ^ rhs); +constexpr E& operator^=(E& lhs, E rhs) noexcept { + return lhs = (lhs ^ rhs); } -} // namespace bitwise_operators +} // namespace magic_enum::bitwise_operators -} // namespace magic_enum +} // namespace magic_enum #if defined(__clang__) -#pragma clang diagnostic pop +# pragma clang diagnostic pop #elif defined(__GNUC__) -#pragma GCC diagnostic pop +# pragma GCC diagnostic pop #elif defined(_MSC_VER) -#pragma warning(pop) +# pragma warning(pop) #endif #undef MAGIC_ENUM_GET_ENUM_NAME_BUILTIN @@ -2213,4 +1471,4 @@ operator^=(E& lhs, E rhs) noexcept #undef MAGIC_ENUM_ARRAY_CONSTEXPR #undef MAGIC_ENUM_FOR_EACH_256 -#endif // NEARGYE_MAGIC_ENUM_HPP \ No newline at end of file +#endif // NEARGYE_MAGIC_ENUM_HPP diff --git a/src/test/app/Import_test.cpp b/src/test/app/Import_test.cpp index d4e3aabb6..f9fb090be 100644 --- a/src/test/app/Import_test.cpp +++ b/src/test/app/Import_test.cpp @@ -5041,8 +5041,7 @@ class Import_test : public beast::unit_test::suite { for (std::uint32_t const withFeature : {0, 1, 2}) { - auto const amend = withFeature == 0 - ? features + auto const amend = withFeature == 0 ? features : withFeature == 1 ? features - featureXahauGenesis : features - featureDeletableAccounts; test::jtx::Env env{ @@ -5081,8 +5080,9 @@ class Import_test : public beast::unit_test::suite { BEAST_EXPECT((*acctSle)[sfAccountIndex] == 0); } - std::uint64_t const seq = - withFeature == 0 ? 12 : withFeature == 1 ? 6 : 12; + std::uint64_t const seq = withFeature == 0 ? 12 + : withFeature == 1 ? 6 + : 12; BEAST_EXPECT((*acctSle)[sfSequence] == seq); // confirm account count was set @@ -5098,8 +5098,7 @@ class Import_test : public beast::unit_test::suite { for (std::uint32_t const withFeature : {0, 1, 2}) { - auto const amend = withFeature == 0 - ? features + auto const amend = withFeature == 0 ? features : withFeature == 1 ? features - featureXahauGenesis : features - featureDeletableAccounts; test::jtx::Env env{ @@ -5119,8 +5118,9 @@ class Import_test : public beast::unit_test::suite std::uint64_t sequence; }; - std::uint64_t const seq = - withFeature == 0 ? 11 : withFeature == 1 ? 5 : 11; + std::uint64_t const seq = withFeature == 0 ? 11 + : withFeature == 1 ? 5 + : 11; std::array acctTests = {{ {alice, 0, seq}, {bob, 1, seq}, diff --git a/src/test/app/NFTokenBurn_test.cpp b/src/test/app/NFTokenBurn_test.cpp index f633be9f6..ad72ed814 100644 --- a/src/test/app/NFTokenBurn_test.cpp +++ b/src/test/app/NFTokenBurn_test.cpp @@ -313,7 +313,8 @@ class NFTokenBurnBaseUtil_test : public beast::unit_test::suite // Otherwise either alice or minter can burn. AcctStat& burner = owner.acct == becky.acct ? *(stats[acctDist(engine)]) - : mintDist(engine) ? alice : minter; + : mintDist(engine) ? alice + : minter; if (owner.acct == burner.acct) env(token::burn(burner, nft)); diff --git a/src/test/app/Remit_test.cpp b/src/test/app/Remit_test.cpp index 9bc6a654b..b8b298a83 100644 --- a/src/test/app/Remit_test.cpp +++ b/src/test/app/Remit_test.cpp @@ -465,7 +465,6 @@ struct Remit_test : public beast::unit_test::suite // tefBAD_LEDGER - invalid owner directory { - } // tecDIR_FULL - destination directory full diff --git a/src/test/app/SetRemarks_test.cpp b/src/test/app/SetRemarks_test.cpp index f9fa37191..cf2dda6c7 100644 --- a/src/test/app/SetRemarks_test.cpp +++ b/src/test/app/SetRemarks_test.cpp @@ -345,8 +345,9 @@ struct SetRemarks_test : public beast::unit_test::suite env.close(); } // tecCLAIM: SetRemarks: insane remarks accounting. - {} // tecTOO_MANY_REMARKS: SetRemarks: an object may have at most 32 - // remarks. + { + } // tecTOO_MANY_REMARKS: SetRemarks: an object may have at most 32 + // remarks. { std::vector _marks; unsigned int hexValue = 0xEFAC; diff --git a/src/test/app/ValidatorSite_test.cpp b/src/test/app/ValidatorSite_test.cpp index c2c663665..c29df9d8b 100644 --- a/src/test/app/ValidatorSite_test.cpp +++ b/src/test/app/ValidatorSite_test.cpp @@ -78,20 +78,21 @@ private: BEAST_EXPECT(trustedSites->load(emptyCfgSites)); // load should accept valid validator site uris - std::vector cfgSites({ - "http://ripple.com/", "http://ripple.com/validators", - "http://ripple.com:8080/validators", - "http://207.261.33.37/validators", - "http://207.261.33.37:8080/validators", - "https://ripple.com/validators", - "https://ripple.com:443/validators", - "file:///etc/opt/ripple/validators-xahau.txt", - "file:///C:/Lib/validators-xahau.txt" + std::vector cfgSites( + {"http://ripple.com/", + "http://ripple.com/validators", + "http://ripple.com:8080/validators", + "http://207.261.33.37/validators", + "http://207.261.33.37:8080/validators", + "https://ripple.com/validators", + "https://ripple.com:443/validators", + "file:///etc/opt/ripple/validators-xahau.txt", + "file:///C:/Lib/validators-xahau.txt" #if !_MSC_VER - , - "file:///" + , + "file:///" #endif - }); + }); BEAST_EXPECT(trustedSites->load(cfgSites)); // load should reject validator site uris with invalid schemes diff --git a/src/test/basics/IOUAmount_test.cpp b/src/test/basics/IOUAmount_test.cpp index 6e7c66263..e588a08dc 100644 --- a/src/test/basics/IOUAmount_test.cpp +++ b/src/test/basics/IOUAmount_test.cpp @@ -219,55 +219,56 @@ public: tinyNeg == mulRatio(tinyNeg, maxUInt - 1, maxUInt, false)); } - {// rounding - {IOUAmount one(1, 0); - auto const rup = mulRatio(one, maxUInt - 1, maxUInt, true); - auto const rdown = mulRatio(one, maxUInt - 1, maxUInt, false); - BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); - } + { // rounding + { + IOUAmount one(1, 0); + auto const rup = mulRatio(one, maxUInt - 1, maxUInt, true); + auto const rdown = mulRatio(one, maxUInt - 1, maxUInt, false); + BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); + } + { + IOUAmount big(maxMantissa, maxExponent); + auto const rup = mulRatio(big, maxUInt - 1, maxUInt, true); + auto const rdown = mulRatio(big, maxUInt - 1, maxUInt, false); + BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); + } + + { + IOUAmount negOne(-1, 0); + auto const rup = mulRatio(negOne, maxUInt - 1, maxUInt, true); + auto const rdown = + mulRatio(negOne, maxUInt - 1, maxUInt, false); + BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); + } + } + + { + // division by zero + IOUAmount one(1, 0); + except([&] { mulRatio(one, 1, 0, true); }); + } + + { + // overflow + IOUAmount big(maxMantissa, maxExponent); + except([&] { mulRatio(big, 2, 0, true); }); + } + } // namespace ripple + + //-------------------------------------------------------------------------- + + void + run() override { - IOUAmount big(maxMantissa, maxExponent); - auto const rup = mulRatio(big, maxUInt - 1, maxUInt, true); - auto const rdown = mulRatio(big, maxUInt - 1, maxUInt, false); - BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); + testZero(); + testSigNum(); + testBeastZero(); + testComparisons(); + testToString(); + testMulRatio(); } - - { - IOUAmount negOne(-1, 0); - auto const rup = mulRatio(negOne, maxUInt - 1, maxUInt, true); - auto const rdown = mulRatio(negOne, maxUInt - 1, maxUInt, false); - BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); - } -} - -{ - // division by zero - IOUAmount one(1, 0); - except([&] { mulRatio(one, 1, 0, true); }); -} - -{ - // overflow - IOUAmount big(maxMantissa, maxExponent); - except([&] { mulRatio(big, 2, 0, true); }); -} -} // namespace ripple - -//-------------------------------------------------------------------------- - -void -run() override -{ - testZero(); - testSigNum(); - testBeastZero(); - testComparisons(); - testToString(); - testMulRatio(); -} -} -; +}; BEAST_DEFINE_TESTSUITE(IOUAmount, protocol, ripple); -} // ripple +} // namespace ripple diff --git a/src/test/basics/XRPAmount_test.cpp b/src/test/basics/XRPAmount_test.cpp index c4c96dbfb..c57890fcf 100644 --- a/src/test/basics/XRPAmount_test.cpp +++ b/src/test/basics/XRPAmount_test.cpp @@ -283,63 +283,67 @@ public: tinyNeg == mulRatio(tinyNeg, maxUInt32 - 1, maxUInt32, false)); } - {// rounding - {XRPAmount one(1); - auto const rup = mulRatio(one, maxUInt32 - 1, maxUInt32, true); - auto const rdown = mulRatio(one, maxUInt32 - 1, maxUInt32, false); - BEAST_EXPECT(rup.drops() - rdown.drops() == 1); - } + { // rounding + { + XRPAmount one(1); + auto const rup = mulRatio(one, maxUInt32 - 1, maxUInt32, true); + auto const rdown = + mulRatio(one, maxUInt32 - 1, maxUInt32, false); + BEAST_EXPECT(rup.drops() - rdown.drops() == 1); + } + { + XRPAmount big(maxXRP); + auto const rup = mulRatio(big, maxUInt32 - 1, maxUInt32, true); + auto const rdown = + mulRatio(big, maxUInt32 - 1, maxUInt32, false); + BEAST_EXPECT(rup.drops() - rdown.drops() == 1); + } + + { + XRPAmount negOne(-1); + auto const rup = + mulRatio(negOne, maxUInt32 - 1, maxUInt32, true); + auto const rdown = + mulRatio(negOne, maxUInt32 - 1, maxUInt32, false); + BEAST_EXPECT(rup.drops() - rdown.drops() == 1); + } + } + + { + // division by zero + XRPAmount one(1); + except([&] { mulRatio(one, 1, 0, true); }); + } + + { + // overflow + XRPAmount big(maxXRP); + except([&] { mulRatio(big, 2, 1, true); }); + } + + { + // underflow + XRPAmount bigNegative(minXRP + 10); + BEAST_EXPECT(mulRatio(bigNegative, 2, 1, true) == minXRP); + } + } // namespace ripple + + //-------------------------------------------------------------------------- + + void + run() override { - XRPAmount big(maxXRP); - auto const rup = mulRatio(big, maxUInt32 - 1, maxUInt32, true); - auto const rdown = mulRatio(big, maxUInt32 - 1, maxUInt32, false); - BEAST_EXPECT(rup.drops() - rdown.drops() == 1); + testSigNum(); + testBeastZero(); + testComparisons(); + testAddSub(); + testDecimal(); + testFunctions(); + testMulRatio(); } - - { - XRPAmount negOne(-1); - auto const rup = mulRatio(negOne, maxUInt32 - 1, maxUInt32, true); - auto const rdown = mulRatio(negOne, maxUInt32 - 1, maxUInt32, false); - BEAST_EXPECT(rup.drops() - rdown.drops() == 1); - } -} - -{ - // division by zero - XRPAmount one(1); - except([&] { mulRatio(one, 1, 0, true); }); -} - -{ - // overflow - XRPAmount big(maxXRP); - except([&] { mulRatio(big, 2, 1, true); }); -} - -{ - // underflow - XRPAmount bigNegative(minXRP + 10); - BEAST_EXPECT(mulRatio(bigNegative, 2, 1, true) == minXRP); -} -} // namespace ripple - -//-------------------------------------------------------------------------- - -void -run() override -{ - testSigNum(); - testBeastZero(); - testComparisons(); - testAddSub(); - testDecimal(); - testFunctions(); - testMulRatio(); -} -} -; +}; BEAST_DEFINE_TESTSUITE(XRPAmount, protocol, ripple); -} // ripple +} // namespace ripple diff --git a/src/test/basics/base_uint_test.cpp b/src/test/basics/base_uint_test.cpp index 43000a112..9f3194f4f 100644 --- a/src/test/basics/base_uint_test.cpp +++ b/src/test/basics/base_uint_test.cpp @@ -48,7 +48,8 @@ struct nonhash memcpy(data_.data(), key, len); } - explicit operator std::size_t() noexcept + explicit + operator std::size_t() noexcept { return WIDTH; } diff --git a/src/test/beast/beast_Zero_test.cpp b/src/test/beast/beast_Zero_test.cpp index b60716362..8fd16a4d5 100644 --- a/src/test/beast/beast_Zero_test.cpp +++ b/src/test/beast/beast_Zero_test.cpp @@ -27,7 +27,8 @@ struct adl_tester { }; -int signum(adl_tester) +int +signum(adl_tester) { return 0; } @@ -38,7 +39,8 @@ struct adl_tester2 { }; -int signum(adl_tester2) +int +signum(adl_tester2) { return 0; } diff --git a/src/test/consensus/ByzantineFailureSim_test.cpp b/src/test/consensus/ByzantineFailureSim_test.cpp index ce59adbe9..92dbfc017 100644 --- a/src/test/consensus/ByzantineFailureSim_test.cpp +++ b/src/test/consensus/ByzantineFailureSim_test.cpp @@ -66,8 +66,8 @@ class ByzantineFailureSim_test : public beast::unit_test::suite for (TrustGraph::ForkInfo const& fi : sim.trustGraph.forkablePairs(0.8)) { - std::cout << "Can fork " << PeerGroup{fi.unlA} << " " - << " " << PeerGroup{fi.unlB} << " overlap " << fi.overlap + std::cout << "Can fork " << PeerGroup{fi.unlA} << " " << " " + << PeerGroup{fi.unlB} << " overlap " << fi.overlap << " required " << fi.required << "\n"; }; diff --git a/src/test/csf/Peer.h b/src/test/csf/Peer.h index 5eed78569..2f3b460e0 100644 --- a/src/test/csf/Peer.h +++ b/src/test/csf/Peer.h @@ -644,7 +644,8 @@ struct Peer } // Not interested in tracking consensus mode changes for now - void onModeChange(ConsensusMode, ConsensusMode) + void + onModeChange(ConsensusMode, ConsensusMode) { } diff --git a/src/test/csf/collectors.h b/src/test/csf/collectors.h index 511fb2c4b..8dcaa0353 100644 --- a/src/test/csf/collectors.h +++ b/src/test/csf/collectors.h @@ -281,66 +281,62 @@ struct TxCollector if (printBreakline) { - log << std::setw(11) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(36) << std::setfill('-') << "-" - << std::endl; + log << std::setw(11) << std::setfill('-') << "-" << "-" + << std::setw(7) << std::setfill('-') << "-" << "-" + << std::setw(7) << std::setfill('-') << "-" << "-" + << std::setw(36) << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); } - log << std::left << std::setw(11) << "TxStats" - << "|" << std::setw(7) << "Count" - << "|" << std::setw(7) << "Per Sec" - << "|" << std::setw(15) << "Latency (sec)" << std::right - << std::setw(7) << "10-ile" << std::setw(7) << "50-ile" - << std::setw(7) << "90-ile" << std::left << std::endl; + log << std::left << std::setw(11) << "TxStats" << "|" << std::setw(7) + << "Count" << "|" << std::setw(7) << "Per Sec" << "|" + << std::setw(15) << "Latency (sec)" << std::right << std::setw(7) + << "10-ile" << std::setw(7) << "50-ile" << std::setw(7) << "90-ile" + << std::left << std::endl; - log << std::setw(11) << std::setfill('-') << "-" - << "|" << std::setw(7) << std::setfill('-') << "-" - << "|" << std::setw(7) << std::setfill('-') << "-" - << "|" << std::setw(36) << std::setfill('-') << "-" << std::endl; + log << std::setw(11) << std::setfill('-') << "-" << "|" << std::setw(7) + << std::setfill('-') << "-" << "|" << std::setw(7) + << std::setfill('-') << "-" << "|" << std::setw(36) + << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); - log << std::left << std::setw(11) << "Submit " - << "|" << std::right << std::setw(7) << submitted << "|" - << std::setw(7) << std::setprecision(2) << perSec(submitted) << "|" - << std::setw(36) << "" << std::endl; + log << std::left << std::setw(11) << "Submit " << "|" << std::right + << std::setw(7) << submitted << "|" << std::setw(7) + << std::setprecision(2) << perSec(submitted) << "|" << std::setw(36) + << "" << std::endl; - log << std::left << std::setw(11) << "Accept " - << "|" << std::right << std::setw(7) << accepted << "|" - << std::setw(7) << std::setprecision(2) << perSec(accepted) << "|" - << std::setw(15) << std::left << "From Submit" << std::right + log << std::left << std::setw(11) << "Accept " << "|" << std::right + << std::setw(7) << accepted << "|" << std::setw(7) + << std::setprecision(2) << perSec(accepted) << "|" << std::setw(15) + << std::left << "From Submit" << std::right << std::setw(7) + << std::setprecision(2) << fmtS(submitToAccept.percentile(0.1f)) << std::setw(7) << std::setprecision(2) - << fmtS(submitToAccept.percentile(0.1f)) << std::setw(7) - << std::setprecision(2) << fmtS(submitToAccept.percentile(0.5f)) + << fmtS(submitToAccept.percentile(0.5f)) << std::setw(7) + << std::setprecision(2) << fmtS(submitToAccept.percentile(0.9f)) + << std::endl; + + log << std::left << std::setw(11) << "Validate " << "|" << std::right + << std::setw(7) << validated << "|" << std::setw(7) + << std::setprecision(2) << perSec(validated) << "|" << std::setw(15) + << std::left << "From Submit" << std::right << std::setw(7) + << std::setprecision(2) << fmtS(submitToValidate.percentile(0.1f)) << std::setw(7) << std::setprecision(2) - << fmtS(submitToAccept.percentile(0.9f)) << std::endl; + << fmtS(submitToValidate.percentile(0.5f)) << std::setw(7) + << std::setprecision(2) << fmtS(submitToValidate.percentile(0.9f)) + << std::endl; - log << std::left << std::setw(11) << "Validate " - << "|" << std::right << std::setw(7) << validated << "|" - << std::setw(7) << std::setprecision(2) << perSec(validated) << "|" - << std::setw(15) << std::left << "From Submit" << std::right - << std::setw(7) << std::setprecision(2) - << fmtS(submitToValidate.percentile(0.1f)) << std::setw(7) - << std::setprecision(2) << fmtS(submitToValidate.percentile(0.5f)) - << std::setw(7) << std::setprecision(2) - << fmtS(submitToValidate.percentile(0.9f)) << std::endl; + log << std::left << std::setw(11) << "Orphan" << "|" << std::right + << std::setw(7) << orphaned() << "|" << std::setw(7) << "" << "|" + << std::setw(36) << std::endl; - log << std::left << std::setw(11) << "Orphan" - << "|" << std::right << std::setw(7) << orphaned() << "|" - << std::setw(7) << "" - << "|" << std::setw(36) << std::endl; + log << std::left << std::setw(11) << "Unvalidated" << "|" << std::right + << std::setw(7) << unvalidated() << "|" << std::setw(7) << "" << "|" + << std::setw(43) << std::endl; - log << std::left << std::setw(11) << "Unvalidated" - << "|" << std::right << std::setw(7) << unvalidated() << "|" - << std::setw(7) << "" - << "|" << std::setw(43) << std::endl; - - log << std::setw(11) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(36) << std::setfill('-') << "-" << std::endl; + log << std::setw(11) << std::setfill('-') << "-" << "-" << std::setw(7) + << std::setfill('-') << "-" << "-" << std::setw(7) + << std::setfill('-') << "-" << "-" << std::setw(36) + << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); } @@ -362,34 +358,15 @@ struct TxCollector if (printHeaders) { - log << "tag" - << "," - << "txNumSubmitted" - << "," - << "txNumAccepted" - << "," - << "txNumValidated" - << "," - << "txNumOrphaned" - << "," - << "txUnvalidated" - << "," - << "txRateSumbitted" - << "," - << "txRateAccepted" - << "," - << "txRateValidated" - << "," - << "txLatencySubmitToAccept10Pctl" - << "," - << "txLatencySubmitToAccept50Pctl" - << "," - << "txLatencySubmitToAccept90Pctl" - << "," - << "txLatencySubmitToValidatet10Pctl" - << "," - << "txLatencySubmitToValidatet50Pctl" - << "," + log << "tag" << "," << "txNumSubmitted" << "," << "txNumAccepted" + << "," << "txNumValidated" << "," << "txNumOrphaned" << "," + << "txUnvalidated" << "," << "txRateSumbitted" << "," + << "txRateAccepted" << "," << "txRateValidated" << "," + << "txLatencySubmitToAccept10Pctl" << "," + << "txLatencySubmitToAccept50Pctl" << "," + << "txLatencySubmitToAccept90Pctl" << "," + << "txLatencySubmitToValidatet10Pctl" << "," + << "txLatencySubmitToValidatet50Pctl" << "," << "txLatencySubmitToValidatet90Pctl" << std::endl; } @@ -548,52 +525,50 @@ struct LedgerCollector if (printBreakline) { - log << std::setw(11) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(36) << std::setfill('-') << "-" - << std::endl; + log << std::setw(11) << std::setfill('-') << "-" << "-" + << std::setw(7) << std::setfill('-') << "-" << "-" + << std::setw(7) << std::setfill('-') << "-" << "-" + << std::setw(36) << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); } - log << std::left << std::setw(11) << "LedgerStats" - << "|" << std::setw(7) << "Count" - << "|" << std::setw(7) << "Per Sec" + log << std::left << std::setw(11) << "LedgerStats" << "|" + << std::setw(7) << "Count" << "|" << std::setw(7) << "Per Sec" << "|" << std::setw(15) << "Latency (sec)" << std::right << std::setw(7) << "10-ile" << std::setw(7) << "50-ile" << std::setw(7) << "90-ile" << std::left << std::endl; - log << std::setw(11) << std::setfill('-') << "-" - << "|" << std::setw(7) << std::setfill('-') << "-" - << "|" << std::setw(7) << std::setfill('-') << "-" - << "|" << std::setw(36) << std::setfill('-') << "-" << std::endl; + log << std::setw(11) << std::setfill('-') << "-" << "|" << std::setw(7) + << std::setfill('-') << "-" << "|" << std::setw(7) + << std::setfill('-') << "-" << "|" << std::setw(36) + << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); - log << std::left << std::setw(11) << "Accept " - << "|" << std::right << std::setw(7) << accepted << "|" - << std::setw(7) << std::setprecision(2) << perSec(accepted) << "|" - << std::setw(15) << std::left << "From Accept" << std::right + log << std::left << std::setw(11) << "Accept " << "|" << std::right + << std::setw(7) << accepted << "|" << std::setw(7) + << std::setprecision(2) << perSec(accepted) << "|" << std::setw(15) + << std::left << "From Accept" << std::right << std::setw(7) + << std::setprecision(2) << fmtS(acceptToAccept.percentile(0.1f)) << std::setw(7) << std::setprecision(2) - << fmtS(acceptToAccept.percentile(0.1f)) << std::setw(7) - << std::setprecision(2) << fmtS(acceptToAccept.percentile(0.5f)) - << std::setw(7) << std::setprecision(2) - << fmtS(acceptToAccept.percentile(0.9f)) << std::endl; + << fmtS(acceptToAccept.percentile(0.5f)) << std::setw(7) + << std::setprecision(2) << fmtS(acceptToAccept.percentile(0.9f)) + << std::endl; - log << std::left << std::setw(11) << "Validate " - << "|" << std::right << std::setw(7) << fullyValidated << "|" - << std::setw(7) << std::setprecision(2) << perSec(fullyValidated) - << "|" << std::setw(15) << std::left << "From Validate " - << std::right << std::setw(7) << std::setprecision(2) + log << std::left << std::setw(11) << "Validate " << "|" << std::right + << std::setw(7) << fullyValidated << "|" << std::setw(7) + << std::setprecision(2) << perSec(fullyValidated) << "|" + << std::setw(15) << std::left << "From Validate " << std::right + << std::setw(7) << std::setprecision(2) << fmtS(fullyValidToFullyValid.percentile(0.1f)) << std::setw(7) << std::setprecision(2) << fmtS(fullyValidToFullyValid.percentile(0.5f)) << std::setw(7) << std::setprecision(2) << fmtS(fullyValidToFullyValid.percentile(0.9f)) << std::endl; - log << std::setw(11) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(36) << std::setfill('-') << "-" << std::endl; + log << std::setw(11) << std::setfill('-') << "-" << "-" << std::setw(7) + << std::setfill('-') << "-" << "-" << std::setw(7) + << std::setfill('-') << "-" << "-" << std::setw(36) + << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); } @@ -615,26 +590,14 @@ struct LedgerCollector if (printHeaders) { - log << "tag" - << "," - << "ledgerNumAccepted" - << "," - << "ledgerNumFullyValidated" - << "," - << "ledgerRateAccepted" - << "," - << "ledgerRateFullyValidated" - << "," - << "ledgerLatencyAcceptToAccept10Pctl" - << "," - << "ledgerLatencyAcceptToAccept50Pctl" - << "," - << "ledgerLatencyAcceptToAccept90Pctl" - << "," - << "ledgerLatencyFullyValidToFullyValid10Pctl" - << "," - << "ledgerLatencyFullyValidToFullyValid50Pctl" - << "," + log << "tag" << "," << "ledgerNumAccepted" << "," + << "ledgerNumFullyValidated" << "," << "ledgerRateAccepted" + << "," << "ledgerRateFullyValidated" << "," + << "ledgerLatencyAcceptToAccept10Pctl" << "," + << "ledgerLatencyAcceptToAccept50Pctl" << "," + << "ledgerLatencyAcceptToAccept90Pctl" << "," + << "ledgerLatencyFullyValidToFullyValid10Pctl" << "," + << "ledgerLatencyFullyValidToFullyValid50Pctl" << "," << "ledgerLatencyFullyValidToFullyValid90Pctl" << std::endl; } @@ -695,16 +658,16 @@ struct StreamCollector on(PeerID who, SimTime when, AcceptLedger const& e) { out << when.time_since_epoch().count() << ": Node " << who - << " accepted " - << "L" << e.ledger.id() << " " << e.ledger.txs() << "\n"; + << " accepted " << "L" << e.ledger.id() << " " << e.ledger.txs() + << "\n"; } void on(PeerID who, SimTime when, FullyValidateLedger const& e) { out << when.time_since_epoch().count() << ": Node " << who - << " fully-validated " - << "L" << e.ledger.id() << " " << e.ledger.txs() << "\n"; + << " fully-validated " << "L" << e.ledger.id() << " " + << e.ledger.txs() << "\n"; } }; diff --git a/src/test/jtx/TestHelpers.h b/src/test/jtx/TestHelpers.h index 0d51bab35..882658d2e 100644 --- a/src/test/jtx/TestHelpers.h +++ b/src/test/jtx/TestHelpers.h @@ -39,11 +39,11 @@ namespace jtx { // when we have moved to better compilers. template auto -make_vector(Input const& input) requires requires(Input& v) -{ - std::begin(v); - std::end(v); -} +make_vector(Input const& input) + requires requires(Input& v) { + std::begin(v); + std::end(v); + } { return std::vector(std::begin(input), std::end(input)); } diff --git a/src/test/jtx/TrustedPublisherServer.h b/src/test/jtx/TrustedPublisherServer.h index 2daa57f4f..d14526e9a 100644 --- a/src/test/jtx/TrustedPublisherServer.h +++ b/src/test/jtx/TrustedPublisherServer.h @@ -218,9 +218,8 @@ public: getList_ = [blob = blob, sig, manifest, version](int interval) { // Build the contents of a version 1 format UNL file std::stringstream l; - l << "{\"blob\":\"" << blob << "\"" - << ",\"signature\":\"" << sig << "\"" - << ",\"manifest\":\"" << manifest << "\"" + l << "{\"blob\":\"" << blob << "\"" << ",\"signature\":\"" << sig + << "\"" << ",\"manifest\":\"" << manifest << "\"" << ",\"refresh_interval\": " << interval << ",\"version\":" << version << '}'; return l.str(); @@ -255,15 +254,14 @@ public: std::stringstream l; for (auto const& info : blobInfo) { - l << "{\"blob\":\"" << info.blob << "\"" - << ",\"signature\":\"" << info.signature << "\"},"; + l << "{\"blob\":\"" << info.blob << "\"" << ",\"signature\":\"" + << info.signature << "\"},"; } std::string blobs = l.str(); blobs.pop_back(); l.str(std::string()); l << "{\"blobs_v2\": [ " << blobs << "],\"manifest\":\"" << manifest - << "\"" - << ",\"refresh_interval\": " << interval + << "\"" << ",\"refresh_interval\": " << interval << ",\"version\":" << (version + 1) << '}'; return l.str(); }; diff --git a/src/test/jtx/amount.h b/src/test/jtx/amount.h index c8e0d0c37..459ec5b5c 100644 --- a/src/test/jtx/amount.h +++ b/src/test/jtx/amount.h @@ -126,7 +126,7 @@ public: return amount_; } - operator STAmount const &() const + operator STAmount const&() const { return amount_; } @@ -211,7 +211,8 @@ struct XRP_t /** @} */ /** Returns None-of-XRP */ - None operator()(none_t) const + None + operator()(none_t) const { return {xrpIssue()}; } @@ -327,14 +328,17 @@ public: return {amountFromString(issue(), std::to_string(v)), account.name()}; } - PrettyAmount operator()(epsilon_t) const; - PrettyAmount operator()(detail::epsilon_multiple) const; + PrettyAmount + operator()(epsilon_t) const; + PrettyAmount + operator()(detail::epsilon_multiple) const; // VFALCO TODO // STAmount operator()(char const* s) const; /** Returns None-of-Issue */ - None operator()(none_t) const + None + operator()(none_t) const { return {issue()}; } diff --git a/src/test/jtx/impl/AMM.cpp b/src/test/jtx/impl/AMM.cpp index c083b6df3..8c369e685 100644 --- a/src/test/jtx/impl/AMM.cpp +++ b/src/test/jtx/impl/AMM.cpp @@ -42,8 +42,8 @@ static IOUAmount initialTokens(STAmount const& asset1, STAmount const& asset2) { auto const product = number(asset1) * number(asset2); - return (IOUAmount)( - product.mantissa() >= 0 ? root2(product) : root2(-product)); + return (IOUAmount)(product.mantissa() >= 0 ? root2(product) + : root2(-product)); } AMM::AMM( diff --git a/src/test/jtx/impl/amount.cpp b/src/test/jtx/impl/amount.cpp index 01fa53695..9f374c2cb 100644 --- a/src/test/jtx/impl/amount.cpp +++ b/src/test/jtx/impl/amount.cpp @@ -104,7 +104,8 @@ operator<<(std::ostream& os, PrettyAmount const& amount) XRP_t const XRP{}; -PrettyAmount IOU::operator()(epsilon_t) const +PrettyAmount +IOU::operator()(epsilon_t) const { return {STAmount(issue(), 1, -81), account.name()}; } diff --git a/src/test/jtx/multisign.h b/src/test/jtx/multisign.h index e1e93eac2..a96accd3a 100644 --- a/src/test/jtx/multisign.h +++ b/src/test/jtx/multisign.h @@ -102,9 +102,8 @@ public: msig(std::vector signers_); template - requires std::convertible_to explicit msig( - AccountType&& a0, - Accounts&&... aN) + requires std::convertible_to + explicit msig(AccountType&& a0, Accounts&&... aN) : msig{std::vector{ std::forward(a0), std::forward(aN)...}} diff --git a/src/test/overlay/reduce_relay_test.cpp b/src/test/overlay/reduce_relay_test.cpp index 4d9086dab..e0b0d006a 100644 --- a/src/test/overlay/reduce_relay_test.cpp +++ b/src/test/overlay/reduce_relay_test.cpp @@ -888,9 +888,8 @@ protected: printPeers(const std::string& msg, std::uint16_t validator = 0) { auto peers = network_.overlay().getPeers(network_.validator(validator)); - std::cout << msg << " " - << "num peers " << (int)network_.overlay().getNumPeers() - << std::endl; + std::cout << msg << " " << "num peers " + << (int)network_.overlay().getNumPeers() << std::endl; for (auto& [k, v] : peers) std::cout << k << ":" << (int)std::get(v) << " "; diff --git a/src/test/protocol/MultiApiJson_test.cpp b/src/test/protocol/MultiApiJson_test.cpp index 2c0b410f8..a5c37d257 100644 --- a/src/test/protocol/MultiApiJson_test.cpp +++ b/src/test/protocol/MultiApiJson_test.cpp @@ -105,8 +105,8 @@ struct MultiApiJson_test : beast::unit_test::suite BEAST_EXPECT(!s1.valid(0)); BEAST_EXPECT(!s1.valid(RPC::apiMaximumValidVersion + 1)); BEAST_EXPECT( - !s1.valid(std::numeric_limits::max())); + !s1.valid(std::numeric_limits< + decltype(RPC::apiMaximumValidVersion.value)>::max())); int result = 1; static_assert( @@ -165,32 +165,28 @@ struct MultiApiJson_test : beast::unit_test::suite // Several overloads we want to fail static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // [](Json::Value&, auto) {}); // missing const }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // [](Json::Value&) {}); // missing const }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // []() {}); // missing parameters }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // [](auto) {}, @@ -198,8 +194,7 @@ struct MultiApiJson_test : beast::unit_test::suite }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // [](auto, auto) {}, @@ -207,8 +202,7 @@ struct MultiApiJson_test : beast::unit_test::suite }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // [](auto, auto, const char*) {}, @@ -218,40 +212,35 @@ struct MultiApiJson_test : beast::unit_test::suite // Sanity checks static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](auto) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](Json::Value const&) {}); }; }(std::as_const(s1))); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](Json::Value const&, auto...) {}); }; }(std::as_const(s1))); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](Json::Value&, auto, auto, auto...) {}, @@ -260,8 +249,7 @@ struct MultiApiJson_test : beast::unit_test::suite }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // []( @@ -274,16 +262,14 @@ struct MultiApiJson_test : beast::unit_test::suite }; }(std::as_const(s1))); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](auto...) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](auto...) {}); @@ -342,45 +328,25 @@ struct MultiApiJson_test : beast::unit_test::suite // Tests of requires clause - these are expected to match static_assert([](auto&& v) { - return requires - { - v.set("name", Json::nullValue); - }; + return requires { v.set("name", Json::nullValue); }; }(x)); static_assert([](auto&& v) { - return requires - { - v.set("name", "value"); - }; - }(x)); - static_assert([](auto&& v) { - return requires - { - v.set("name", true); - }; - }(x)); - static_assert([](auto&& v) { - return requires - { - v.set("name", 42); - }; + return requires { v.set("name", "value"); }; }(x)); + static_assert( + [](auto&& v) { return requires { v.set("name", true); }; }(x)); + static_assert( + [](auto&& v) { return requires { v.set("name", 42); }; }(x)); // Tests of requires clause - these are expected NOT to match struct foo_t final { }; static_assert([](auto&& v) { - return !requires - { - v.set("name", foo_t{}); - }; + return !requires { v.set("name", foo_t{}); }; }(x)); static_assert([](auto&& v) { - return !requires - { - v.set("name", std::nullopt); - }; + return !requires { v.set("name", std::nullopt); }; }(x)); } @@ -436,8 +402,7 @@ struct MultiApiJson_test : beast::unit_test::suite // Test different overloads static_assert([](auto&& v) { - return requires - { + return requires { v.visitor( v, std::integral_constant{}, @@ -458,8 +423,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor( v, std::integral_constant{}, @@ -476,8 +440,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor( v, std::integral_constant{}, @@ -498,8 +461,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor( v, std::integral_constant{}, @@ -516,8 +478,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor(v, 1, [](Json::Value&, unsigned) {}); }; }(s1)); @@ -533,10 +494,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](Json::Value&) {}); - }; + return requires { v.visitor(v, 1, [](Json::Value&) {}); }; }(s1)); BEAST_EXPECT( s1.visitor( @@ -548,8 +506,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor(v, 1, [](Json::Value const&, unsigned) {}); }; }(std::as_const(s1))); @@ -565,10 +522,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](Json::Value const&) {}); - }; + return requires { v.visitor(v, 1, [](Json::Value const&) {}); }; }(std::as_const(s1))); BEAST_EXPECT( s1.visitor( @@ -671,8 +625,7 @@ struct MultiApiJson_test : beast::unit_test::suite // Several overloads we want to fail static_assert([](auto&& v) { - return !requires - { + return !requires { v.visitor( v, 1, // @@ -681,8 +634,7 @@ struct MultiApiJson_test : beast::unit_test::suite }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { v.visitor( std::move(v), // cannot bind rvalue 1, @@ -691,8 +643,7 @@ struct MultiApiJson_test : beast::unit_test::suite }(s1)); static_assert([](auto&& v) { - return !requires - { + return !requires { v.visitor( v, 1, // @@ -701,8 +652,7 @@ struct MultiApiJson_test : beast::unit_test::suite }(s1)); static_assert([](auto&& v) { - return !requires - { + return !requires { v.visitor( v, 1, // @@ -712,74 +662,52 @@ struct MultiApiJson_test : beast::unit_test::suite // Want these to be unambiguous static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](auto) {}); - }; + return requires { v.visitor(v, 1, [](auto) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](Json::Value&) {}); - }; + return requires { v.visitor(v, 1, [](Json::Value&) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor(v, 1, [](Json::Value&, auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](Json::Value const&) {}); - }; + return requires { v.visitor(v, 1, [](Json::Value const&) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor(v, 1, [](Json::Value const&, auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](auto...) {}); - }; + return requires { v.visitor(v, 1, [](auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](auto, auto...) {}); - }; + return requires { v.visitor(v, 1, [](auto, auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor(v, 1, [](auto, auto, auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor( - v, 1, [](auto, auto, auto...) {}, ""); + return requires { + v.visitor(v, 1, [](auto, auto, auto...) {}, ""); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor( - v, 1, [](auto, auto, auto, auto...) {}, ""); + return requires { + v.visitor(v, 1, [](auto, auto, auto, auto...) {}, ""); }; }(s1)); } @@ -794,8 +722,7 @@ struct MultiApiJson_test : beast::unit_test::suite // Test different overloads static_assert([](auto&& v) { - return requires - { + return requires { v.visit( std::integral_constant{}, [](Json::Value&, std::integral_constant) { @@ -813,8 +740,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value const&, auto) { return 0; }, [](auto, auto) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()( std::integral_constant{}, [](Json::Value&, std::integral_constant) { @@ -833,8 +759,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visit( std::integral_constant{}, [](Json::Value&) {}); @@ -848,8 +773,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value const&) { return 0; }, [](auto...) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()( std::integral_constant{}, [](Json::Value&) {}); @@ -864,8 +788,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visit( std::integral_constant{}, [](Json::Value const&, @@ -883,8 +806,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value&, auto) { return 0; }, [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()( std::integral_constant{}, [](Json::Value const&, @@ -903,8 +825,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visit( std::integral_constant{}, [](Json::Value const&) {}); @@ -918,8 +839,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value&) { return 0; }, [](auto...) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()( std::integral_constant{}, [](Json::Value const&) {}); @@ -934,10 +854,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { - v.visit(1, [](Json::Value&, unsigned) {}); - }; + return requires { v.visit(1, [](Json::Value&, unsigned) {}); }; }(s1)); BEAST_EXPECT( s1.visit( @@ -950,8 +867,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value&, auto) { return 0; }, [](auto, auto) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()(1, [](Json::Value&, unsigned) {}); }; }(s1)); @@ -967,10 +883,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { - v.visit(1, [](Json::Value&) {}); - }; + return requires { v.visit(1, [](Json::Value&) {}); }; }(s1)); BEAST_EXPECT( s1.visit( @@ -980,10 +893,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value const&) { return 0; }, [](auto...) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { - v.visit()(1, [](Json::Value&) {}); - }; + return requires { v.visit()(1, [](Json::Value&) {}); }; }(s1)); BEAST_EXPECT( s1.visit()( @@ -994,8 +904,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { + return requires { v.visit(1, [](Json::Value const&, unsigned) {}); }; }(std::as_const(s1))); @@ -1010,8 +919,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value&, unsigned) { return 0; }, [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()(1, [](Json::Value const&, unsigned) {}); }; }(std::as_const(s1))); @@ -1027,10 +935,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { - v.visit(1, [](Json::Value const&) {}); - }; + return requires { v.visit(1, [](Json::Value const&) {}); }; }(std::as_const(s1))); BEAST_EXPECT( std::as_const(s1).visit( @@ -1040,10 +945,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value&) { return 0; }, [](auto...) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { - v.visit()(1, [](Json::Value const&) {}); - }; + return requires { v.visit()(1, [](Json::Value const&) {}); }; }(std::as_const(s1))); BEAST_EXPECT( std::as_const(s1).visit()( @@ -1055,83 +957,71 @@ struct MultiApiJson_test : beast::unit_test::suite // Rvalue MultivarJson visitor only binds to regular reference static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit(1, [](Json::Value&&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit( 1, [](Json::Value const&&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit(1, [](Json::Value&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit( 1, [](Json::Value const&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit()( 1, [](Json::Value&&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit()( 1, [](Json::Value const&&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit()( 1, [](Json::Value&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit()( 1, [](Json::Value const&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit( 1, [](Json::Value const&&) {}); }; }(std::move(std::as_const(s1)))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit( 1, [](Json::Value const&) {}); }; }(std::move(std::as_const(s1)))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit()( 1, [](Json::Value const&&) {}); }; }(std::move(std::as_const(s1)))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit()( 1, [](Json::Value const&) {}); }; @@ -1139,15 +1029,13 @@ struct MultiApiJson_test : beast::unit_test::suite // Missing const static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit( 1, [](Json::Value&, auto) {}); }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit()( 1, [](Json::Value&, auto) {}); }; @@ -1155,28 +1043,24 @@ struct MultiApiJson_test : beast::unit_test::suite // Missing parameter static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit(1, []() {}); }; }(s1)); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit()(1, []() {}); }; }(s1)); // Sanity checks static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit(1, [](auto...) {}); }; }(std::as_const(s1))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit()(1, [](auto...) {}); }; }(std::as_const(s1))); diff --git a/src/test/protocol/STObject_test.cpp b/src/test/protocol/STObject_test.cpp index 39a5b9c2f..41c3800bc 100644 --- a/src/test/protocol/STObject_test.cpp +++ b/src/test/protocol/STObject_test.cpp @@ -243,9 +243,8 @@ public: unexpected(sfGeneric.isUseful(), "sfGeneric must not be useful"); { // Try to put sfGeneric in an SOTemplate. - except([&]() { - SOTemplate elements{{sfGeneric, soeREQUIRED}}; - }); + except( + [&]() { SOTemplate elements{{sfGeneric, soeREQUIRED}}; }); } unexpected(sfInvalid.isUseful(), "sfInvalid must not be useful"); @@ -263,9 +262,8 @@ public: } { // Try to put sfInvalid in an SOTemplate. - except([&]() { - SOTemplate elements{{sfInvalid, soeREQUIRED}}; - }); + except( + [&]() { SOTemplate elements{{sfInvalid, soeREQUIRED}}; }); } { // Try to put the same SField into an SOTemplate twice. @@ -570,150 +568,152 @@ public: // STBlob and slice - {{STObject st(sfGeneric); - Buffer b(1); - BEAST_EXPECT(!b.empty()); - st[sf4] = std::move(b); - BEAST_EXPECT(b.empty()); - BEAST_EXPECT(Slice(st[sf4]).size() == 1); - st[~sf4] = std::nullopt; - BEAST_EXPECT(!~st[~sf4]); - b = Buffer{2}; - st[sf4] = Slice(b); - BEAST_EXPECT(b.size() == 2); - BEAST_EXPECT(Slice(st[sf4]).size() == 2); - st[sf5] = st[sf4]; - BEAST_EXPECT(Slice(st[sf4]).size() == 2); - BEAST_EXPECT(Slice(st[sf5]).size() == 2); - } + { + { + STObject st(sfGeneric); + Buffer b(1); + BEAST_EXPECT(!b.empty()); + st[sf4] = std::move(b); + BEAST_EXPECT(b.empty()); + BEAST_EXPECT(Slice(st[sf4]).size() == 1); + st[~sf4] = std::nullopt; + BEAST_EXPECT(!~st[~sf4]); + b = Buffer{2}; + st[sf4] = Slice(b); + BEAST_EXPECT(b.size() == 2); + BEAST_EXPECT(Slice(st[sf4]).size() == 2); + st[sf5] = st[sf4]; + BEAST_EXPECT(Slice(st[sf4]).size() == 2); + BEAST_EXPECT(Slice(st[sf5]).size() == 2); + } + { + STObject st(sotOuter, sfGeneric); + BEAST_EXPECT(st[sf5] == Slice{}); + BEAST_EXPECT(!!st[~sf5]); + BEAST_EXPECT(!!~st[~sf5]); + Buffer b(1); + st[sf5] = std::move(b); + BEAST_EXPECT(b.empty()); + BEAST_EXPECT(Slice(st[sf5]).size() == 1); + st[~sf4] = std::nullopt; + BEAST_EXPECT(!~st[~sf4]); + } + } + + // UDT blobs + + { + STObject st(sfGeneric); + BEAST_EXPECT(!st[~sf5]); + auto const kp = generateKeyPair( + KeyType::secp256k1, generateSeed("masterpassphrase")); + st[sf5] = kp.first; + st[~sf5] = std::nullopt; + } + + // By reference fields + + { + auto const& sf = sfIndexes; + STObject st(sfGeneric); + std::vector v; + v.emplace_back(1); + v.emplace_back(2); + st[sf] = v; + st[sf] = std::move(v); + auto const& cst = st; + BEAST_EXPECT(cst[sf].size() == 2); + BEAST_EXPECT(cst[~sf]->size() == 2); + BEAST_EXPECT(cst[sf][0] == 1); + BEAST_EXPECT(cst[sf][1] == 2); + static_assert( + std::is_same< + decltype(cst[sfIndexes]), + std::vector const&>::value, + ""); + } + + // Default by reference field + + { + auto const& sf1 = sfIndexes; + auto const& sf2 = sfHashes; + auto const& sf3 = sfAmendments; + SOTemplate const sot{ + {sf1, soeREQUIRED}, + {sf2, soeOPTIONAL}, + {sf3, soeDEFAULT}, + }; + + STObject st(sot, sfGeneric); + auto const& cst(st); + BEAST_EXPECT(cst[sf1].size() == 0); + BEAST_EXPECT(!cst[~sf2]); + BEAST_EXPECT(cst[sf3].size() == 0); + std::vector v; + v.emplace_back(1); + st[sf1] = v; + BEAST_EXPECT(cst[sf1].size() == 1); + BEAST_EXPECT(cst[sf1][0] == uint256{1}); + st[sf2] = v; + BEAST_EXPECT(cst[sf2].size() == 1); + BEAST_EXPECT(cst[sf2][0] == uint256{1}); + st[~sf2] = std::nullopt; + BEAST_EXPECT(!st[~sf2]); + st[sf3] = v; + BEAST_EXPECT(cst[sf3].size() == 1); + BEAST_EXPECT(cst[sf3][0] == uint256{1}); + st[sf3] = std::vector{}; + BEAST_EXPECT(cst[sf3].size() == 0); + } + } // namespace ripple + + void + testMalformed() { - STObject st(sotOuter, sfGeneric); - BEAST_EXPECT(st[sf5] == Slice{}); - BEAST_EXPECT(!!st[~sf5]); - BEAST_EXPECT(!!~st[~sf5]); - Buffer b(1); - st[sf5] = std::move(b); - BEAST_EXPECT(b.empty()); - BEAST_EXPECT(Slice(st[sf5]).size() == 1); - st[~sf4] = std::nullopt; - BEAST_EXPECT(!~st[~sf4]); + testcase("Malformed serialized forms"); + + try + { + std::array const payload{ + {0xe9, 0x12, 0xab, 0xcd, 0x12, 0xfe, 0xdc}}; + SerialIter sit{makeSlice(payload)}; + auto obj = std::make_shared(sit, sfMetadata); + BEAST_EXPECT(!obj); + } + catch (std::exception const& e) + { + BEAST_EXPECT(strcmp(e.what(), "Duplicate field detected") == 0); + } + + try + { + std::array const payload{{0xe2, 0xe1, 0xe2}}; + SerialIter sit{makeSlice(payload)}; + auto obj = std::make_shared(sit, sfMetadata); + BEAST_EXPECT(!obj); + } + catch (std::exception const& e) + { + BEAST_EXPECT(strcmp(e.what(), "Duplicate field detected") == 0); + } } -} -// UDT blobs - -{ - STObject st(sfGeneric); - BEAST_EXPECT(!st[~sf5]); - auto const kp = - generateKeyPair(KeyType::secp256k1, generateSeed("masterpassphrase")); - st[sf5] = kp.first; - st[~sf5] = std::nullopt; -} - -// By reference fields - -{ - auto const& sf = sfIndexes; - STObject st(sfGeneric); - std::vector v; - v.emplace_back(1); - v.emplace_back(2); - st[sf] = v; - st[sf] = std::move(v); - auto const& cst = st; - BEAST_EXPECT(cst[sf].size() == 2); - BEAST_EXPECT(cst[~sf]->size() == 2); - BEAST_EXPECT(cst[sf][0] == 1); - BEAST_EXPECT(cst[sf][1] == 2); - static_assert( - std::is_same const&>:: - value, - ""); -} - -// Default by reference field - -{ - auto const& sf1 = sfIndexes; - auto const& sf2 = sfHashes; - auto const& sf3 = sfAmendments; - SOTemplate const sot{ - {sf1, soeREQUIRED}, - {sf2, soeOPTIONAL}, - {sf3, soeDEFAULT}, - }; - - STObject st(sot, sfGeneric); - auto const& cst(st); - BEAST_EXPECT(cst[sf1].size() == 0); - BEAST_EXPECT(!cst[~sf2]); - BEAST_EXPECT(cst[sf3].size() == 0); - std::vector v; - v.emplace_back(1); - st[sf1] = v; - BEAST_EXPECT(cst[sf1].size() == 1); - BEAST_EXPECT(cst[sf1][0] == uint256{1}); - st[sf2] = v; - BEAST_EXPECT(cst[sf2].size() == 1); - BEAST_EXPECT(cst[sf2][0] == uint256{1}); - st[~sf2] = std::nullopt; - BEAST_EXPECT(!st[~sf2]); - st[sf3] = v; - BEAST_EXPECT(cst[sf3].size() == 1); - BEAST_EXPECT(cst[sf3][0] == uint256{1}); - st[sf3] = std::vector{}; - BEAST_EXPECT(cst[sf3].size() == 0); -} -} // namespace ripple - -void -testMalformed() -{ - testcase("Malformed serialized forms"); - - try + void + run() override { - std::array const payload{ - {0xe9, 0x12, 0xab, 0xcd, 0x12, 0xfe, 0xdc}}; - SerialIter sit{makeSlice(payload)}; - auto obj = std::make_shared(sit, sfMetadata); - BEAST_EXPECT(!obj); - } - catch (std::exception const& e) - { - BEAST_EXPECT(strcmp(e.what(), "Duplicate field detected") == 0); - } + // Instantiate a jtx::Env so debugLog writes are exercised. + test::jtx::Env env(*this); - try - { - std::array const payload{{0xe2, 0xe1, 0xe2}}; - SerialIter sit{makeSlice(payload)}; - auto obj = std::make_shared(sit, sfMetadata); - BEAST_EXPECT(!obj); + testFields(); + testSerialization(); + testParseJSONArray(); + testParseJSONArrayWithInvalidChildrenObjects(); + testParseJSONEdgeCases(); + testMalformed(); } - catch (std::exception const& e) - { - BEAST_EXPECT(strcmp(e.what(), "Duplicate field detected") == 0); - } -} - -void -run() override -{ - // Instantiate a jtx::Env so debugLog writes are exercised. - test::jtx::Env env(*this); - - testFields(); - testSerialization(); - testParseJSONArray(); - testParseJSONArrayWithInvalidChildrenObjects(); - testParseJSONEdgeCases(); - testMalformed(); -} -} -; +}; BEAST_DEFINE_TESTSUITE(STObject, protocol, ripple); -} // ripple +} // namespace ripple diff --git a/src/xrpld/app/hook/detail/HookAPI.cpp b/src/xrpld/app/hook/detail/HookAPI.cpp index f0ba95efa..305b06a58 100644 --- a/src/xrpld/app/hook/detail/HookAPI.cpp +++ b/src/xrpld/app/hook/detail/HookAPI.cpp @@ -541,8 +541,8 @@ HookAPI::sto_emplace( } std::vector out( - (size_t)( - source_object.size() + (field_object ? field_object->size() : 0)), + (size_t)(source_object.size() + + (field_object ? field_object->size() : 0)), (uint8_t)0); uint8_t* write_ptr = out.data(); @@ -2635,9 +2635,9 @@ HookAPI::xpop_slot(uint32_t slot_into_tx, uint32_t slot_into_meta) const size_t free_count = hook_api::max_slots - hookCtx.slot.size(); - size_t needed_count = slot_into_tx == 0 && slot_into_meta == 0 - ? 2 - : slot_into_tx != 0 && slot_into_meta != 0 ? 0 : 1; + size_t needed_count = slot_into_tx == 0 && slot_into_meta == 0 ? 2 + : slot_into_tx != 0 && slot_into_meta != 0 ? 0 + : 1; if (free_count < needed_count) return Unexpected(NO_FREE_SLOTS); diff --git a/src/xrpld/app/hook/detail/applyHook.cpp b/src/xrpld/app/hook/detail/applyHook.cpp index 7bcac14be..fb51dbf35 100644 --- a/src/xrpld/app/hook/detail/applyHook.cpp +++ b/src/xrpld/app/hook/detail/applyHook.cpp @@ -916,8 +916,8 @@ hook::getHookCanEmit( (hookObj.isFieldPresent(sfHookCanEmit) ? hookObj.getFieldH256(sfHookCanEmit) : hookDef->isFieldPresent(sfHookCanEmit) - ? hookDef->getFieldH256(sfHookCanEmit) - : defaultHookCanEmit); + ? hookDef->getFieldH256(sfHookCanEmit) + : defaultHookCanEmit); return hookCanEmit; } @@ -2252,10 +2252,10 @@ DEFINE_HOOK_FUNCTION( ripple::Keylet kl = keylet_type == keylet_code::CHILD ? ripple::keylet::child(id) : keylet_type == keylet_code::EMITTED_TXN - ? ripple::keylet::emittedTxn(id) - : keylet_type == keylet_code::HOOK_DEFINITION - ? ripple::keylet::hookDefinition(id) - : ripple::keylet::unchecked(id); + ? ripple::keylet::emittedTxn(id) + : keylet_type == keylet_code::HOOK_DEFINITION + ? ripple::keylet::hookDefinition(id) + : ripple::keylet::unchecked(id); return serialize_keylet(kl, memory, write_ptr, write_len); } @@ -2284,10 +2284,10 @@ DEFINE_HOOK_FUNCTION( ripple::Keylet kl = keylet_type == keylet_code::HOOK ? ripple::keylet::hook(id) : keylet_type == keylet_code::SIGNERS - ? ripple::keylet::signers(id) - : keylet_type == keylet_code::OWNER_DIR - ? ripple::keylet::ownerDir(id) - : ripple::keylet::account(id); + ? ripple::keylet::signers(id) + : keylet_type == keylet_code::OWNER_DIR + ? ripple::keylet::ownerDir(id) + : ripple::keylet::account(id); return serialize_keylet(kl, memory, write_ptr, write_len); } @@ -2328,10 +2328,10 @@ DEFINE_HOOK_FUNCTION( ripple::Keylet kl = keylet_type == keylet_code::CHECK ? ripple::keylet::check(id, seq) : keylet_type == keylet_code::ESCROW - ? ripple::keylet::escrow(id, seq) - : keylet_type == keylet_code::NFT_OFFER - ? ripple::keylet::nftoffer(id, seq) - : ripple::keylet::offer(id, seq); + ? ripple::keylet::escrow(id, seq) + : keylet_type == keylet_code::NFT_OFFER + ? ripple::keylet::nftoffer(id, seq) + : ripple::keylet::offer(id, seq); return serialize_keylet(kl, memory, write_ptr, write_len); } @@ -2479,13 +2479,11 @@ DEFINE_HOOK_FUNCTION( WRITE_WASM_MEMORY_AND_RETURN( write_ptr, write_len, - keylet_type == keylet_code::AMENDMENTS - ? cAmendments.data() - : keylet_type == keylet_code::FEES - ? cFees.data() - : keylet_type == keylet_code::NEGATIVE_UNL - ? cNegativeUNL.data() - : cEmittedDir.data(), + keylet_type == keylet_code::AMENDMENTS ? cAmendments.data() + : keylet_type == keylet_code::FEES ? cFees.data() + : keylet_type == keylet_code::NEGATIVE_UNL + ? cNegativeUNL.data() + : cEmittedDir.data(), 34, memory, memory_length); diff --git a/src/xrpld/app/ledger/LedgerHistory.cpp b/src/xrpld/app/ledger/LedgerHistory.cpp index dd7575d19..c2cb300cc 100644 --- a/src/xrpld/app/ledger/LedgerHistory.cpp +++ b/src/xrpld/app/ledger/LedgerHistory.cpp @@ -204,30 +204,30 @@ log_metadata_difference( { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different result and index!"; - JLOG(j.debug()) << " Built:" - << " Result: " << builtMetaData->getResult() - << " Index: " << builtMetaData->getIndex(); - JLOG(j.debug()) << " Valid:" - << " Result: " << validMetaData->getResult() - << " Index: " << validMetaData->getIndex(); + JLOG(j.debug()) + << " Built:" << " Result: " << builtMetaData->getResult() + << " Index: " << builtMetaData->getIndex(); + JLOG(j.debug()) + << " Valid:" << " Result: " << validMetaData->getResult() + << " Index: " << validMetaData->getIndex(); } else if (result_diff) { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different result!"; - JLOG(j.debug()) << " Built:" - << " Result: " << builtMetaData->getResult(); - JLOG(j.debug()) << " Valid:" - << " Result: " << validMetaData->getResult(); + JLOG(j.debug()) + << " Built:" << " Result: " << builtMetaData->getResult(); + JLOG(j.debug()) + << " Valid:" << " Result: " << validMetaData->getResult(); } else if (index_diff) { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different index!"; - JLOG(j.debug()) << " Built:" - << " Index: " << builtMetaData->getIndex(); - JLOG(j.debug()) << " Valid:" - << " Index: " << validMetaData->getIndex(); + JLOG(j.debug()) + << " Built:" << " Index: " << builtMetaData->getIndex(); + JLOG(j.debug()) + << " Valid:" << " Index: " << validMetaData->getIndex(); } } else @@ -246,12 +246,12 @@ log_metadata_difference( JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different result and nodes!"; JLOG(j.debug()) - << " Built:" - << " Result: " << builtMetaData->getResult() << " Nodes:\n" + << " Built:" << " Result: " << builtMetaData->getResult() + << " Nodes:\n" << builtNodes.getJson(JsonOptions::none); JLOG(j.debug()) - << " Valid:" - << " Result: " << validMetaData->getResult() << " Nodes:\n" + << " Valid:" << " Result: " << validMetaData->getResult() + << " Nodes:\n" << validNodes.getJson(JsonOptions::none); } else if (index_diff) @@ -259,23 +259,21 @@ log_metadata_difference( JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different index and nodes!"; JLOG(j.debug()) - << " Built:" - << " Index: " << builtMetaData->getIndex() << " Nodes:\n" + << " Built:" << " Index: " << builtMetaData->getIndex() + << " Nodes:\n" << builtNodes.getJson(JsonOptions::none); JLOG(j.debug()) - << " Valid:" - << " Index: " << validMetaData->getIndex() << " Nodes:\n" + << " Valid:" << " Index: " << validMetaData->getIndex() + << " Nodes:\n" << validNodes.getJson(JsonOptions::none); } else // nodes_diff { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different nodes!"; - JLOG(j.debug()) << " Built:" - << " Nodes:\n" + JLOG(j.debug()) << " Built:" << " Nodes:\n" << builtNodes.getJson(JsonOptions::none); - JLOG(j.debug()) << " Valid:" - << " Nodes:\n" + JLOG(j.debug()) << " Valid:" << " Nodes:\n" << validNodes.getJson(JsonOptions::none); } } @@ -330,10 +328,10 @@ LedgerHistory::handleMismatch( if (!builtLedger || !validLedger) { - JLOG(j_.error()) << "MISMATCH cannot be analyzed:" - << " builtLedger: " << to_string(built) << " -> " - << builtLedger << " validLedger: " << to_string(valid) - << " -> " << validLedger; + JLOG(j_.error()) << "MISMATCH cannot be analyzed:" << " builtLedger: " + << to_string(built) << " -> " << builtLedger + << " validLedger: " << to_string(valid) << " -> " + << validLedger; return; } diff --git a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp index 9d677dbe5..f70e54f8c 100644 --- a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp +++ b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp @@ -100,8 +100,8 @@ TimeoutCounter::invokeOnTimer() if (!progress_) { ++timeouts_; - JLOG(journal_.debug()) << "Timeout(" << timeouts_ << ") " - << " acquiring " << hash_; + JLOG(journal_.debug()) + << "Timeout(" << timeouts_ << ") " << " acquiring " << hash_; onTimer(false, sl); } else diff --git a/src/xrpld/app/main/GRPCServer.cpp b/src/xrpld/app/main/GRPCServer.cpp index 89c3d813c..5a231dfc9 100644 --- a/src/xrpld/app/main/GRPCServer.cpp +++ b/src/xrpld/app/main/GRPCServer.cpp @@ -447,8 +447,8 @@ GRPCServerImpl::handleRpcs() if (!ok) { - JLOG(journal_.debug()) << "Request listener cancelled. " - << "Destroying object"; + JLOG(journal_.debug()) + << "Request listener cancelled. " << "Destroying object"; erase(ptr); } else diff --git a/src/xrpld/app/misc/AMMHelpers.h b/src/xrpld/app/misc/AMMHelpers.h index 8bf5a5c5f..7ad0093a2 100644 --- a/src/xrpld/app/misc/AMMHelpers.h +++ b/src/xrpld/app/misc/AMMHelpers.h @@ -385,9 +385,9 @@ changeSpotPriceQuality( { JLOG(j.error()) << "changeSpotPriceQuality failed: " << to_string(pool.in) - << " " << to_string(pool.out) << " " - << " " << quality << " " << tfee << " " - << to_string(amounts.in) << " " << to_string(amounts.out); + << " " << to_string(pool.out) << " " << " " << quality + << " " << tfee << " " << to_string(amounts.in) << " " + << to_string(amounts.out); Throw("changeSpotPriceQuality failed"); } else diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 7d6b973bc..a07f46d0e 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -3215,8 +3215,8 @@ NetworkOPsImp::pubAccountTransaction( } JLOG(m_journal.trace()) - << "pubAccountTransaction: " - << "proposed=" << iProposed << ", accepted=" << iAccepted; + << "pubAccountTransaction: " << "proposed=" << iProposed + << ", accepted=" << iAccepted; if (!notify.empty() || !accountHistoryNotify.empty()) { diff --git a/src/xrpld/app/misc/detail/TxQ.cpp b/src/xrpld/app/misc/detail/TxQ.cpp index 3e0672bb7..7cb304e4b 100644 --- a/src/xrpld/app/misc/detail/TxQ.cpp +++ b/src/xrpld/app/misc/detail/TxQ.cpp @@ -1749,11 +1749,11 @@ TxQ::accept(Application& app, OpenView& view) } else { - JLOG(j_.debug()) << "Queued transaction " << candidateIter->txID - << " failed with " << transToken(txnResult) - << ". Leave in queue." - << " Applied: " << didApply - << ". Flags: " << candidateIter->flags; + JLOG(j_.debug()) + << "Queued transaction " << candidateIter->txID + << " failed with " << transToken(txnResult) + << ". Leave in queue." << " Applied: " << didApply + << ". Flags: " << candidateIter->flags; if (account.retryPenalty && candidateIter->retriesRemaining > 2) candidateIter->retriesRemaining = 1; else diff --git a/src/xrpld/app/misc/detail/ValidatorList.cpp b/src/xrpld/app/misc/detail/ValidatorList.cpp index a3854106a..9a323e011 100644 --- a/src/xrpld/app/misc/detail/ValidatorList.cpp +++ b/src/xrpld/app/misc/detail/ValidatorList.cpp @@ -689,8 +689,7 @@ ValidatorList::sendValidatorList( beast::Journal j) { std::size_t const messageVersion = - peer.supportsFeature(ProtocolFeature::ValidatorList2Propagation) - ? 2 + peer.supportsFeature(ProtocolFeature::ValidatorList2Propagation) ? 2 : peer.supportsFeature(ProtocolFeature::ValidatorListPropagation) ? 1 : 0; if (!messageVersion) diff --git a/src/xrpld/app/paths/Pathfinder.cpp b/src/xrpld/app/paths/Pathfinder.cpp index b123d5daf..2b5c5d10e 100644 --- a/src/xrpld/app/paths/Pathfinder.cpp +++ b/src/xrpld/app/paths/Pathfinder.cpp @@ -233,8 +233,7 @@ Pathfinder::findPaths( mSource = STPathElement(account, mSrcCurrency, issuer); auto issuerString = mSrcIssuer ? to_string(*mSrcIssuer) : std::string("none"); - JLOG(j_.trace()) << "findPaths>" - << " mSrcAccount=" << mSrcAccount + JLOG(j_.trace()) << "findPaths>" << " mSrcAccount=" << mSrcAccount << " mDstAccount=" << mDstAccount << " mDstAmount=" << mDstAmount.getFullText() << " mSrcCurrency=" << mSrcCurrency diff --git a/src/xrpld/app/paths/detail/BookStep.cpp b/src/xrpld/app/paths/detail/BookStep.cpp index 26cb67bb2..8a9826f32 100644 --- a/src/xrpld/app/paths/detail/BookStep.cpp +++ b/src/xrpld/app/paths/detail/BookStep.cpp @@ -188,8 +188,7 @@ protected: logStringImpl(char const* name) const { std::ostringstream ostr; - ostr << name << ": " - << "\ninIss: " << book_.in.account + ostr << name << ": " << "\ninIss: " << book_.in.account << "\noutIss: " << book_.out.account << "\ninCur: " << book_.in.currency << "\noutCur: " << book_.out.currency; diff --git a/src/xrpld/app/paths/detail/DirectStep.cpp b/src/xrpld/app/paths/detail/DirectStep.cpp index af53ffca6..d60e995ad 100644 --- a/src/xrpld/app/paths/detail/DirectStep.cpp +++ b/src/xrpld/app/paths/detail/DirectStep.cpp @@ -204,8 +204,7 @@ protected: logStringImpl(char const* name) const { std::ostringstream ostr; - ostr << name << ": " - << "\nSrc: " << src_ << "\nDst: " << dst_; + ostr << name << ": " << "\nSrc: " << src_ << "\nDst: " << dst_; return ostr.str(); } @@ -236,7 +235,8 @@ public: using DirectStepI::DirectStepI; using DirectStepI::check; - bool verifyPrevStepDebtDirection(DebtDirection) const + bool + verifyPrevStepDebtDirection(DebtDirection) const { // A payment doesn't care whether or not prevStepRedeems. return true; diff --git a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp index 770a5bd5e..54b17336a 100644 --- a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp +++ b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp @@ -132,8 +132,7 @@ protected: logStringImpl(char const* name) const { std::ostringstream ostr; - ostr << name << ": " - << "\nAcc: " << acc_; + ostr << name << ": " << "\nAcc: " << acc_; return ostr.str(); } diff --git a/src/xrpld/app/rdb/RelationalDatabase.h b/src/xrpld/app/rdb/RelationalDatabase.h index 00e236f20..5b06aa24d 100644 --- a/src/xrpld/app/rdb/RelationalDatabase.h +++ b/src/xrpld/app/rdb/RelationalDatabase.h @@ -237,8 +237,8 @@ rangeCheckedCast(C c) /* This should never happen */ assert(0); JLOG(debugLog().error()) - << "rangeCheckedCast domain error:" - << " value = " << c << " min = " << std::numeric_limits::lowest() + << "rangeCheckedCast domain error:" << " value = " << c + << " min = " << std::numeric_limits::lowest() << " max: " << std::numeric_limits::max(); } diff --git a/src/xrpld/app/tx/detail/AMMCreate.cpp b/src/xrpld/app/tx/detail/AMMCreate.cpp index 2ab20fe5e..2a75a5969 100644 --- a/src/xrpld/app/tx/detail/AMMCreate.cpp +++ b/src/xrpld/app/tx/detail/AMMCreate.cpp @@ -250,8 +250,8 @@ applyCreate( ctx_.view().rules().enabled(featureXahauGenesis) ? ctx_.view().info().parentCloseTime.time_since_epoch().count() : ctx_.view().rules().enabled(featureDeletableAccounts) - ? ctx_.view().seq() - : 1}; + ? ctx_.view().seq() + : 1}; sleAMMRoot->setFieldU32(sfSequence, seqno); // Ignore reserves requirement, disable the master key, allow default // rippling (AMM LPToken can be used in payments and offer crossing but diff --git a/src/xrpld/app/tx/detail/CancelOffer.cpp b/src/xrpld/app/tx/detail/CancelOffer.cpp index d3912b6d7..c91ca9bd4 100644 --- a/src/xrpld/app/tx/detail/CancelOffer.cpp +++ b/src/xrpld/app/tx/detail/CancelOffer.cpp @@ -34,8 +34,8 @@ CancelOffer::preflight(PreflightContext const& ctx) if (uTxFlags & tfUniversalMask) { - JLOG(ctx.j.trace()) << "Malformed transaction: " - << "Invalid flags set."; + JLOG(ctx.j.trace()) + << "Malformed transaction: " << "Invalid flags set."; return temINVALID_FLAG; } diff --git a/src/xrpld/app/tx/detail/Import.cpp b/src/xrpld/app/tx/detail/Import.cpp index 91a548cbc..24791edee 100644 --- a/src/xrpld/app/tx/detail/Import.cpp +++ b/src/xrpld/app/tx/detail/Import.cpp @@ -1308,8 +1308,8 @@ Import::doApply() view().rules().enabled(featureXahauGenesis) ? view().info().parentCloseTime.time_since_epoch().count() : view().rules().enabled(featureDeletableAccounts) - ? view().seq() - : 1}; + ? view().seq() + : 1}; sle = std::make_shared(keylet::account(id)); sle->setAccountID(sfAccount, id); diff --git a/src/xrpld/app/tx/detail/Payment.cpp b/src/xrpld/app/tx/detail/Payment.cpp index 6c5272670..2806a9798 100644 --- a/src/xrpld/app/tx/detail/Payment.cpp +++ b/src/xrpld/app/tx/detail/Payment.cpp @@ -56,8 +56,7 @@ Payment::preflight(PreflightContext const& ctx) if (uTxFlags & tfPaymentMask) { - JLOG(j.trace()) << "Malformed transaction: " - << "Invalid flags set."; + JLOG(j.trace()) << "Malformed transaction: " << "Invalid flags set."; return temINVALID_FLAG; } @@ -102,20 +101,19 @@ Payment::preflight(PreflightContext const& ctx) } if (bMax && maxSourceAmount <= beast::zero) { - JLOG(j.trace()) << "Malformed transaction: " - << "bad max amount: " << maxSourceAmount.getFullText(); + JLOG(j.trace()) << "Malformed transaction: " << "bad max amount: " + << maxSourceAmount.getFullText(); return temBAD_AMOUNT; } if (saDstAmount <= beast::zero) { - JLOG(j.trace()) << "Malformed transaction: " - << "bad dst amount: " << saDstAmount.getFullText(); + JLOG(j.trace()) << "Malformed transaction: " << "bad dst amount: " + << saDstAmount.getFullText(); return temBAD_AMOUNT; } if (isBadCurrency(uSrcCurrency) || isBadCurrency(uDstCurrency)) { - JLOG(j.trace()) << "Malformed transaction: " - << "Bad currency."; + JLOG(j.trace()) << "Malformed transaction: " << "Bad currency."; return temBAD_CURRENCY; } if (account == uDstAccountID && uSrcCurrency == uDstCurrency && !bPaths) @@ -327,8 +325,8 @@ Payment::doApply() view().rules().enabled(featureXahauGenesis) ? view().info().parentCloseTime.time_since_epoch().count() : view().rules().enabled(featureDeletableAccounts) - ? view().seq() - : 1}; + ? view().seq() + : 1}; // Create the account. sleDst = std::make_shared(k); @@ -461,8 +459,8 @@ Payment::doApply() { // Vote no. However the transaction might succeed, if applied in // a different order. - JLOG(j_.trace()) << "Delay transaction: Insufficient funds: " - << " " << to_string(mPriorBalance) << " / " + JLOG(j_.trace()) << "Delay transaction: Insufficient funds: " << " " + << to_string(mPriorBalance) << " / " << to_string(saDstAmount.xrp() + mmm) << " (" << to_string(reserve) << ")"; diff --git a/src/xrpld/app/tx/detail/Remit.cpp b/src/xrpld/app/tx/detail/Remit.cpp index 73ca8abe5..5528d10d9 100644 --- a/src/xrpld/app/tx/detail/Remit.cpp +++ b/src/xrpld/app/tx/detail/Remit.cpp @@ -319,7 +319,8 @@ Remit::doApply() std::uint32_t const seqno{ sb.rules().enabled(featureXahauGenesis) ? sb.info().parentCloseTime.time_since_epoch().count() - : sb.rules().enabled(featureDeletableAccounts) ? sb.seq() : 1}; + : sb.rules().enabled(featureDeletableAccounts) ? sb.seq() + : 1}; sleDstAcc = std::make_shared(keylet::account(dstAccID)); sleDstAcc->setAccountID(sfAccount, dstAccID); diff --git a/src/xrpld/app/tx/detail/Transactor.cpp b/src/xrpld/app/tx/detail/Transactor.cpp index 40239c0a8..08ddeb02d 100644 --- a/src/xrpld/app/tx/detail/Transactor.cpp +++ b/src/xrpld/app/tx/detail/Transactor.cpp @@ -479,9 +479,9 @@ Transactor::checkFee(PreclaimContext const& ctx, XRPAmount baseFee) if (balance < feePaid) { - JLOG(ctx.j.trace()) << "Insufficient balance:" - << " balance=" << to_string(balance) - << " paid=" << to_string(feePaid); + JLOG(ctx.j.trace()) + << "Insufficient balance:" << " balance=" << to_string(balance) + << " paid=" << to_string(feePaid); if ((balance > beast::zero) && !ctx.view.open()) { diff --git a/src/xrpld/app/tx/detail/URIToken.cpp b/src/xrpld/app/tx/detail/URIToken.cpp index f20da718f..452fe8429 100644 --- a/src/xrpld/app/tx/detail/URIToken.cpp +++ b/src/xrpld/app/tx/detail/URIToken.cpp @@ -756,10 +756,9 @@ URIToken::doApply() true); } - initSellerBal = !sleDstLine - ? purchaseAmount.zeroed() - : sellerLow ? ((*sleDstLine)[sfBalance]) - : -((*sleDstLine)[sfBalance]); + initSellerBal = !sleDstLine ? purchaseAmount.zeroed() + : sellerLow ? ((*sleDstLine)[sfBalance]) + : -((*sleDstLine)[sfBalance]); finSellerBal = *initSellerBal + *dstAmt; } diff --git a/src/xrpld/conditions/detail/PreimageSha256.h b/src/xrpld/conditions/detail/PreimageSha256.h index c0eca96b0..5185ded7a 100644 --- a/src/xrpld/conditions/detail/PreimageSha256.h +++ b/src/xrpld/conditions/detail/PreimageSha256.h @@ -137,7 +137,8 @@ public: return {type(), cost(), fingerprint()}; } - bool validate(Slice) const override + bool + validate(Slice) const override { // Perhaps counterintuitively, the message isn't // relevant. diff --git a/src/xrpld/consensus/Consensus.h b/src/xrpld/consensus/Consensus.h index cd17b00d9..4a5951ed0 100644 --- a/src/xrpld/consensus/Consensus.h +++ b/src/xrpld/consensus/Consensus.h @@ -1060,8 +1060,7 @@ Consensus::checkLedger() { JLOG(j_.warn()) << "View of consensus changed during " << to_string(phase_) << " status=" << to_string(phase_) - << ", " - << " mode=" << to_string(mode_.get()); + << ", " << " mode=" << to_string(mode_.get()); JLOG(j_.warn()) << prevLedgerID_ << " to " << netLgr; JLOG(j_.warn()) << Json::Compact{previousLedger_.getJson()}; JLOG(j_.debug()) << "State on consensus change " @@ -1164,8 +1163,7 @@ Consensus::shouldPause() const << "roundTime: " << result_->roundTime.read().count() << ", " << "max consensus time: " << parms.ledgerMAX_CONSENSUS.count() << ", " << "validators: " << totalValidators << ", " - << "laggards: " << laggards << ", " - << "offline: " << offline << ", " + << "laggards: " << laggards << ", " << "offline: " << offline << ", " << "quorum: " << quorum << ")"; if (!ahead || !laggards || !totalValidators || !adaptor_.validator() || @@ -1491,8 +1489,8 @@ Consensus::updateOurPositions() if (!haveCloseTimeConsensus_) { JLOG(j_.debug()) - << "No CT consensus:" - << " Proposers:" << currPeerPositions_.size() + << "No CT consensus:" << " Proposers:" + << currPeerPositions_.size() << " Mode:" << to_string(mode_.get()) << " Thresh:" << threshConsensus << " Pos:" << consensusCloseTime.time_since_epoch().count(); diff --git a/src/xrpld/consensus/Validations.h b/src/xrpld/consensus/Validations.h index ed07858d3..a1171effb 100644 --- a/src/xrpld/consensus/Validations.h +++ b/src/xrpld/consensus/Validations.h @@ -482,8 +482,7 @@ private: withTrie(std::lock_guard const& lock, F&& f) { // Call current to flush any stale validations - current( - lock, [](auto) {}, [](auto, auto) {}); + current(lock, [](auto) {}, [](auto, auto) {}); checkAcquired(lock); return f(trie_); } diff --git a/src/xrpld/core/DatabaseCon.h b/src/xrpld/core/DatabaseCon.h index 935147815..c8c40dec6 100644 --- a/src/xrpld/core/DatabaseCon.h +++ b/src/xrpld/core/DatabaseCon.h @@ -73,7 +73,8 @@ public: { return session_.get(); } - explicit operator bool() const + explicit + operator bool() const { return bool(session_); } diff --git a/src/xrpld/ledger/View.h b/src/xrpld/ledger/View.h index 2562f94c6..8565044d4 100644 --- a/src/xrpld/ledger/View.h +++ b/src/xrpld/ledger/View.h @@ -488,7 +488,8 @@ struct RunType { // see: // http://alumni.media.mit.edu/~rahimi/compile-time-flags/ - constexpr operator T() const + constexpr + operator T() const { static_assert(std::is_same::value); return V; diff --git a/src/xrpld/ledger/detail/View.cpp b/src/xrpld/ledger/detail/View.cpp index 2a2da7697..2cf8f5a40 100644 --- a/src/xrpld/ledger/detail/View.cpp +++ b/src/xrpld/ledger/detail/View.cpp @@ -421,8 +421,7 @@ xrpLiquid( STAmount const amount = (balance < reserve) ? STAmount{0} : balance - reserve; - JLOG(j.trace()) << "accountHolds:" - << " account=" << to_string(id) + JLOG(j.trace()) << "accountHolds:" << " account=" << to_string(id) << " amount=" << amount.getFullText() << " fullBalance=" << fullBalance.getFullText() << " balance=" << balance.getFullText() diff --git a/src/xrpld/nodestore/detail/DatabaseNodeImp.h b/src/xrpld/nodestore/detail/DatabaseNodeImp.h index fbb6b304e..91b14875a 100644 --- a/src/xrpld/nodestore/detail/DatabaseNodeImp.h +++ b/src/xrpld/nodestore/detail/DatabaseNodeImp.h @@ -106,7 +106,8 @@ public: store(NodeObjectType type, Blob&& data, uint256 const& hash, std::uint32_t) override; - bool isSameDB(std::uint32_t, std::uint32_t) override + bool + isSameDB(std::uint32_t, std::uint32_t) override { // only one database return true; diff --git a/src/xrpld/nodestore/detail/DatabaseRotatingImp.h b/src/xrpld/nodestore/detail/DatabaseRotatingImp.h index a2914cb41..69cda798e 100644 --- a/src/xrpld/nodestore/detail/DatabaseRotatingImp.h +++ b/src/xrpld/nodestore/detail/DatabaseRotatingImp.h @@ -65,7 +65,8 @@ public: void importDatabase(Database& source) override; - bool isSameDB(std::uint32_t, std::uint32_t) override + bool + isSameDB(std::uint32_t, std::uint32_t) override { // rotating store acts as one logical database return true; diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index 9df85d668..510c2924c 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -590,7 +590,7 @@ PeerImp::fail(std::string const& reason) return post( strand_, std::bind( - (void (Peer::*)(std::string const&)) & PeerImp::fail, + (void(Peer::*)(std::string const&)) & PeerImp::fail, shared_from_this(), reason)); if (journal_.active(beast::severities::kWarning) && socket_.is_open()) @@ -1225,8 +1225,8 @@ PeerImp::handleTransaction( { // If we've never been in synch, there's nothing we can do // with a transaction - JLOG(p_journal_.debug()) << "Ignoring incoming transaction: " - << "Need network ledger"; + JLOG(p_journal_.debug()) + << "Ignoring incoming transaction: " << "Need network ledger"; return; } diff --git a/src/xrpld/overlay/detail/ProtocolVersion.cpp b/src/xrpld/overlay/detail/ProtocolVersion.cpp index bd2effa63..0fecb301f 100644 --- a/src/xrpld/overlay/detail/ProtocolVersion.cpp +++ b/src/xrpld/overlay/detail/ProtocolVersion.cpp @@ -45,7 +45,7 @@ constexpr ProtocolVersion const supportedProtocolList[] // ascending order and doesn't contain any duplicates. // FIXME: With C++20 we can use std::is_sorted with an appropriate comparator static_assert( - []() constexpr->bool { + []() constexpr -> bool { auto const len = std::distance( std::begin(supportedProtocolList), std::end(supportedProtocolList)); diff --git a/src/xrpld/peerfinder/detail/Logic.h b/src/xrpld/peerfinder/detail/Logic.h index 0403530ec..3bfb9942c 100644 --- a/src/xrpld/peerfinder/detail/Logic.h +++ b/src/xrpld/peerfinder/detail/Logic.h @@ -1109,9 +1109,9 @@ public: } else { - JLOG(m_journal.error()) << beast::leftw(18) << "Logic failed " - << "'" << source->name() << "' fetch, " - << results.error.message(); + JLOG(m_journal.error()) + << beast::leftw(18) << "Logic failed " << "'" << source->name() + << "' fetch, " << results.error.message(); } } diff --git a/src/xrpld/rpc/detail/ServerHandler.cpp b/src/xrpld/rpc/detail/ServerHandler.cpp index ad476b1dc..f771be274 100644 --- a/src/xrpld/rpc/detail/ServerHandler.cpp +++ b/src/xrpld/rpc/detail/ServerHandler.cpp @@ -449,9 +449,9 @@ logDuration( beast::Journal& journal) { using namespace std::chrono_literals; - auto const level = (duration >= 10s) - ? journal.error() - : (duration >= 1s) ? journal.warn() : journal.debug(); + auto const level = (duration >= 10s) ? journal.error() + : (duration >= 1s) ? journal.warn() + : journal.debug(); JLOG(level) << "RPC request processing duration = " << std::chrono::duration_cast( diff --git a/src/xrpld/shamap/detail/TaggedPointer.ipp b/src/xrpld/shamap/detail/TaggedPointer.ipp index 309913c79..487b88e34 100644 --- a/src/xrpld/shamap/detail/TaggedPointer.ipp +++ b/src/xrpld/shamap/detail/TaggedPointer.ipp @@ -55,8 +55,8 @@ constexpr size_t elementSizeBytes = constexpr size_t blockSizeBytes = kilobytes(512); template -constexpr std::array initArrayChunkSizeBytes( - std::index_sequence) +constexpr std::array +initArrayChunkSizeBytes(std::index_sequence) { return std::array{ boundaries[I] * elementSizeBytes..., @@ -66,8 +66,8 @@ constexpr auto arrayChunkSizeBytes = initArrayChunkSizeBytes(std::make_index_sequence{}); template -constexpr std::array initArrayChunksPerBlock( - std::index_sequence) +constexpr std::array +initArrayChunksPerBlock(std::index_sequence) { return std::array{ blockSizeBytes / arrayChunkSizeBytes[I]..., @@ -93,8 +93,8 @@ boundariesIndex(std::uint8_t numChildren) } template -std::array, boundaries.size()> initAllocateArrayFuns( - std::index_sequence) +std::array, boundaries.size()> +initAllocateArrayFuns(std::index_sequence) { return std::array, boundaries.size()>{ boost::singleton_pool< @@ -110,8 +110,8 @@ std::array, boundaries.size()> const allocateArrayFuns = initAllocateArrayFuns(std::make_index_sequence{}); template -std::array, boundaries.size()> initFreeArrayFuns( - std::index_sequence) +std::array, boundaries.size()> +initFreeArrayFuns(std::index_sequence) { return std::array, boundaries.size()>{ static_cast(boost::singleton_pool< @@ -127,8 +127,8 @@ std::array, boundaries.size()> const freeArrayFuns = initFreeArrayFuns(std::make_index_sequence{}); template -std::array, boundaries.size()> initIsFromArrayFuns( - std::index_sequence) +std::array, boundaries.size()> +initIsFromArrayFuns(std::index_sequence) { return std::array, boundaries.size()>{ boost::singleton_pool< diff --git a/src/xrpld/unity/rocksdb.h b/src/xrpld/unity/rocksdb.h index 06ccb116d..4a71dc4b5 100644 --- a/src/xrpld/unity/rocksdb.h +++ b/src/xrpld/unity/rocksdb.h @@ -21,7 +21,7 @@ #define RIPPLE_UNITY_ROCKSDB_H_INCLUDED #if RIPPLE_ROCKSDB_AVAILABLE -//#include +// #include #include #include #include