diff --git a/src/api/common/test/ssl_sha_test.cpp b/src/api/common/test/ssl_sha_test.cpp index 73f35299..00f6458a 100644 --- a/src/api/common/test/ssl_sha_test.cpp +++ b/src/api/common/test/ssl_sha_test.cpp @@ -15,7 +15,7 @@ TEST(SSLTest, Sha256) { static constexpr char kExpectedData[] = {-98, 74, -90, 56, -41, 61, -33, 98, -108, -110, -41, -82, -110, -102, -80, 85, 127, -112, -55, -116, 38, 36, 10, -104, -37, 93, 105, 14, 73, 99, 98, 95}; - EXPECT_TRUE(std::equal(sha256.begin(), sha256.end(), std::begin(kExpectedData), std::end(kExpectedData))); + EXPECT_TRUE(std::ranges::equal(sha256, kExpectedData)); } TEST(SSLTest, ShaBin256) { @@ -23,7 +23,7 @@ TEST(SSLTest, ShaBin256) { static constexpr char kExpectedData[] = {11, -51, -56, -21, -101, 61, 35, 28, 86, 97, -50, -8, 47, -113, -13, -107, -100, -93, 27, 71, 101, -128, -65, 101, -110, -123, 38, 73, 77, 73, -10, -39}; - EXPECT_TRUE(std::equal(actual.begin(), actual.end(), std::begin(kExpectedData), std::end(kExpectedData))); + EXPECT_TRUE(std::ranges::equal(actual, kExpectedData)); } TEST(SSLTest, ShaBin512) { @@ -33,7 +33,7 @@ TEST(SSLTest, ShaBin512) { 87, 22, -61, 82, 89, 52, 105, 2, -89, -76, 63, 4, 95, 124, -24, 93, -46, -104, -87, -110, -80, -77, -66, -43, 26, 126, 114, 101, -68, -66, 75, -62, -93, -77, -124, 78, -121, -96}; - EXPECT_TRUE(std::equal(actual.begin(), actual.end(), std::begin(kExpectedData), std::end(kExpectedData))); + EXPECT_TRUE(std::ranges::equal(actual, kExpectedData)); } TEST(SSLTest, ShaHex256) { @@ -42,7 +42,7 @@ TEST(SSLTest, ShaHex256) { 53, 54, 54, 49, 99, 101, 102, 56, 50, 102, 56, 102, 102, 51, 57, 53, 57, 99, 97, 51, 49, 98, 52, 55, 54, 53, 56, 48, 98, 102, 54, 53, 57, 50, 56, 53, 50, 54, 52, 57, 52, 100, 52, 57, 102, 54, 100, 57}; - EXPECT_TRUE(std::equal(actual.begin(), actual.end(), std::begin(kExpectedData), std::end(kExpectedData))); + EXPECT_TRUE(std::ranges::equal(actual, kExpectedData)); } TEST(SSLTest, ShaHex512) { @@ -54,7 +54,7 @@ TEST(SSLTest, ShaHex512) { 48, 50, 97, 55, 98, 52, 51, 102, 48, 52, 53, 102, 55, 99, 101, 56, 53, 100, 100, 50, 57, 56, 97, 57, 57, 50, 98, 48, 98, 51, 98, 101, 100, 53, 49, 97, 55, 101, 55, 50, 54, 53, 98, 99, 98, 101, 52, 98, 99, 50, 97, 51, 98, 51, 56, 52, 52, 101, 56, 55, 97, 48}; - EXPECT_TRUE(std::equal(actual.begin(), actual.end(), std::begin(kExpectedData), std::end(kExpectedData))); + EXPECT_TRUE(std::ranges::equal(actual, kExpectedData)); } TEST(SSLTest, ShaDigest256) { @@ -63,7 +63,7 @@ TEST(SSLTest, ShaDigest256) { 51, 50, 57, 55, 100, 50, 56, 97, 52, 55, 50, 57, 51, 102, 49, 50, 51, 97, 49, 51, 50, 54, 50, 57, 48, 101, 102, 51, 100, 55, 48, 49, 53, 57, 55, 101, 57, 51, 56, 102, 99, 53, 48, 102, 48, 57, 57, 57}; - EXPECT_TRUE(std::equal(actual.begin(), actual.end(), std::begin(kExpectedData), std::end(kExpectedData))); + EXPECT_TRUE(std::ranges::equal(actual, kExpectedData)); } TEST(SSLTest, ShaDigest512) { @@ -75,7 +75,7 @@ TEST(SSLTest, ShaDigest512) { 50, 49, 99, 100, 100, 57, 54, 102, 50, 52, 48, 54, 48, 102, 101, 49, 56, 102, 52, 52, 50, 100, 54, 57, 100, 98, 54, 99, 56, 53, 56, 49, 53, 51, 52, 57, 102, 50, 52, 101, 99, 100, 99, 48, 100, 97, 51, 51, 51, 53, 48, 49, 56, 51, 53, 98, 53, 52, 51, 102, 54, 53}; - EXPECT_TRUE(std::equal(actual.begin(), actual.end(), std::begin(kExpectedData), std::end(kExpectedData))); + EXPECT_TRUE(std::ranges::equal(actual, kExpectedData)); } TEST(SSLTest, ShaDigest256Multiple) { @@ -86,7 +86,7 @@ TEST(SSLTest, ShaDigest256Multiple) { 100, 57, 97, 52, 48, 99, 51, 52, 101, 97, 50, 99, 53, 98, 97, 51, 100, 54, 55, 50, 102, 100, 51, 102, 100, 98, 51, 54, 52, 100, 98, 50, 101, 49, 97, 56, 53, 54, 99, 48, 100, 53, 52, 98, 49, 101, 51, 50}; - EXPECT_TRUE(std::equal(actual.begin(), actual.end(), std::begin(kExpectedData), std::end(kExpectedData))); + EXPECT_TRUE(std::ranges::equal(actual, kExpectedData)); } TEST(SSLTest, ShaDigest512Multiple) { @@ -100,6 +100,6 @@ TEST(SSLTest, ShaDigest512Multiple) { 48, 56, 54, 49, 100, 57, 49, 51, 98, 97, 57, 53, 56, 54, 54, 54, 52, 53, 53, 48, 57, 98, 100, 99, 102, 57, 54, 52, 55, 55, 49, 55, 48, 56, 97, 55, 50, 102, 52, 54, 52, 101, 56, 50, 51, 102, 57, 54, 98, 53, 50, 51, 52, 99, 98, 48, 51, 56, 100, 53, 55, 56}; - EXPECT_TRUE(std::equal(actual.begin(), actual.end(), std::begin(kExpectedData), std::end(kExpectedData))); + EXPECT_TRUE(std::ranges::equal(actual, kExpectedData)); } } // namespace cct::ssl \ No newline at end of file diff --git a/src/api/exchanges/src/binanceprivateapi.cpp b/src/api/exchanges/src/binanceprivateapi.cpp index 76ea7373..7613444e 100644 --- a/src/api/exchanges/src/binanceprivateapi.cpp +++ b/src/api/exchanges/src/binanceprivateapi.cpp @@ -794,9 +794,9 @@ ReceivedWithdrawInfo BinancePrivate::queryWithdrawDelivery(const InitiatedWithdr _queryDelay, {{"coin", currencyCode.str()}}); const Wallet& wallet = initiatedWithdrawInfo.receivingWallet(); - auto newEndIt = std::remove_if(depositStatus.begin(), depositStatus.end(), [&wallet](const json& el) { - return el["status"].get() != 1 || el["address"].get() != wallet.address(); - }); + auto newEndIt = std::ranges::remove_if(depositStatus, [&wallet](const json& el) { + return el["status"].get() != 1 || el["address"].get() != wallet.address(); + }).begin(); depositStatus.erase(newEndIt, depositStatus.end()); diff --git a/src/api/exchanges/src/bithumbprivateapi.cpp b/src/api/exchanges/src/bithumbprivateapi.cpp index c9d6d568..5856421e 100644 --- a/src/api/exchanges/src/bithumbprivateapi.cpp +++ b/src/api/exchanges/src/bithumbprivateapi.cpp @@ -745,8 +745,8 @@ json QueryUserTransactions(BithumbPrivate& exchangePrivate, CurlHandle& curlHand continue; } } else if (userTransactionEnum == UserTransactionEnum::kClosedOrders) { - const auto searchGb = StringToIntegral(trx["search"].get()); - if (searchGb != kSearchGbBuy && searchGb != kSearchGbSell) { + const auto searchValue = StringToIntegral(trx["search"].get()); + if (searchValue != kSearchGbBuy && searchValue != kSearchGbSell) { continue; } } diff --git a/src/engine/include/queryresultprinter.hpp b/src/engine/include/queryresultprinter.hpp index b0ce8b51..02e4addc 100644 --- a/src/engine/include/queryresultprinter.hpp +++ b/src/engine/include/queryresultprinter.hpp @@ -89,7 +89,8 @@ class QueryResultPrinter { void printConversionPath(Market mk, const ConversionPathPerExchange &conversionPathsPerExchange) const; - void printWithdrawFees(const MonetaryAmountByCurrencySetPerExchange &withdrawFeesPerExchange, CurrencyCode cur) const; + void printWithdrawFees(const MonetaryAmountByCurrencySetPerExchange &withdrawFeesPerExchange, + CurrencyCode currencyCode) const; void printLast24hTradedVolume(Market mk, const MonetaryAmountPerExchange &tradedVolumePerExchange) const; diff --git a/src/engine/src/queryresultprinter.cpp b/src/engine/src/queryresultprinter.cpp index 8438ae83..3daea981 100644 --- a/src/engine/src/queryresultprinter.cpp +++ b/src/engine/src/queryresultprinter.cpp @@ -1352,8 +1352,8 @@ void QueryResultPrinter::printConversionPath(Market mk, } void QueryResultPrinter::printWithdrawFees(const MonetaryAmountByCurrencySetPerExchange &withdrawFeesPerExchange, - CurrencyCode cur) const { - json jsonData = WithdrawFeesJson(withdrawFeesPerExchange, cur); + CurrencyCode currencyCode) const { + json jsonData = WithdrawFeesJson(withdrawFeesPerExchange, currencyCode); switch (_apiOutputType) { case ApiOutputType::kFormattedTable: { table::Row header("Withdraw fee currency"); diff --git a/src/http-request/src/curlhandle.cpp b/src/http-request/src/curlhandle.cpp index 89167f0e..b94a6a56 100644 --- a/src/http-request/src/curlhandle.cpp +++ b/src/http-request/src/curlhandle.cpp @@ -1,6 +1,7 @@ #include "curlhandle.hpp" #include +#include #include #include diff --git a/src/objects/include/currencycode.hpp b/src/objects/include/currencycode.hpp index dbfb4983..2f56794f 100644 --- a/src/objects/include/currencycode.hpp +++ b/src/objects/include/currencycode.hpp @@ -71,6 +71,9 @@ class CurrencyCodeIterator { using pointer = const char *; using reference = const char &; + // Public default constructor needed for an iterator in C++20 + CurrencyCodeIterator() noexcept = default; + constexpr std::strong_ordering operator<=>(const CurrencyCodeIterator &) const noexcept = default; constexpr bool operator==(const CurrencyCodeIterator &) const noexcept = default; @@ -103,11 +106,10 @@ class CurrencyCodeIterator { private: friend class CurrencyCode; - // Default constructor needed for an iterator in C++20 - constexpr explicit CurrencyCodeIterator(uint64_t data = 0, uint64_t pos = 0) noexcept : _data(data), _pos(pos) {} + constexpr explicit CurrencyCodeIterator(uint64_t data, uint64_t pos = 0) noexcept : _data(data), _pos(pos) {} - uint64_t _data; - uint64_t _pos; + uint64_t _data{}; + uint64_t _pos{}; }; /// Lightweight object representing a currency code with its acronym. @@ -278,6 +280,8 @@ class CurrencyCode { } }; +static_assert(std::ranges::bidirectional_range); + } // namespace cct #ifndef CCT_DISABLE_SPDLOG diff --git a/src/objects/test/currencycode_test.cpp b/src/objects/test/currencycode_test.cpp index 14f80d77..4034cee1 100644 --- a/src/objects/test/currencycode_test.cpp +++ b/src/objects/test/currencycode_test.cpp @@ -170,7 +170,7 @@ TEST(CurrencyCodeTest, UpperConversion) { namespace { constexpr bool HasZ(CurrencyCode cur) { - return std::any_of(cur.begin(), cur.end(), [](char ch) { return ch == 'Z'; }); + return std::ranges::any_of(cur, [](char ch) { return ch == 'Z'; }); } } // namespace diff --git a/src/serialization/test/proto-market-order-book-converter_test.cpp b/src/serialization/test/proto-market-order-book-converter_test.cpp index 329c5da3..dfc034a5 100644 --- a/src/serialization/test/proto-market-order-book-converter_test.cpp +++ b/src/serialization/test/proto-market-order-book-converter_test.cpp @@ -4,7 +4,6 @@ #include -#include "amount-price.hpp" #include "market.hpp" #include "marketorderbook.hpp" #include "monetaryamount.hpp" diff --git a/src/tech/include/cct_log.hpp b/src/tech/include/cct_log.hpp index 5a882194..9387e6d6 100644 --- a/src/tech/include/cct_log.hpp +++ b/src/tech/include/cct_log.hpp @@ -5,6 +5,7 @@ #ifdef CCT_DISABLE_SPDLOG #include #else +#include // IWYU pragma: export #include // IWYU pragma: export #endif