Skip to content

Commit

Permalink
Remove obsolete workaround for lack of std::views::reverse.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Jan 29, 2025
1 parent aa8a735 commit 574a62e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
10 changes: 0 additions & 10 deletions include/bitcoin/system/boost.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@
////#include <boost/predef.h> // platform identifications
#include <boost/program_options.hpp>

// C++20 suport for ranges not yet available on other platforms.
#if defined(HAVE_RANGES)
#include <ranges>
#define views_reverse std::views::reverse
#else
// boost::adaptors::reverse is not constexpr.
#include <boost/range/adaptor/reversed.hpp>
#define views_reverse boost::adaptors::reverse
#endif

// ADL free functions for use with boost-json.
#define DECLARE_JSON_VALUE_CONVERTORS(name) \
BC_API name tag_invoke(boost::json::value_to_tag<name>, \
Expand Down
3 changes: 2 additions & 1 deletion include/bitcoin/system/impl/radix/base_16.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define LIBBITCOIN_SYSTEM_RADIX_BASE_16_IPP

#include <algorithm>
#include <ranges>
#include <string>
#include <string_view>
#include <bitcoin/system/data/data.hpp>
Expand Down Expand Up @@ -116,7 +117,7 @@ SRCONSTEXPR std::string encode_hash(const data_slice& hash) NOEXCEPT
auto digit = out.begin();

// views_reverse is RCONSTEXPR
for (const auto byte: views_reverse(hash))
for (const auto byte: std::views::reverse(hash))
{
*digit++ = to_base16_character(shift_right(byte, to_half(byte_bits)));
*digit++ = to_base16_character(bit_and(byte, 0x0f_u8));
Expand Down
3 changes: 2 additions & 1 deletion src/chain/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <iterator>
#include <memory>
#include <numeric>
#include <ranges>
#include <set>
#include <type_traits>
#include <utility>
Expand Down Expand Up @@ -619,7 +620,7 @@ bool block::is_invalid_witness_commitment() const NOEXCEPT
// Last output of commitment pattern holds the committed value (bip141).
hash_digest reserved{}, committed{};
if (coinbase->inputs_ptr()->front()->reserved_hash(reserved))
for (const auto& output: views_reverse(*coinbase->outputs_ptr()))
for (const auto& output: std::views::reverse(*coinbase->outputs_ptr()))
if (output->committed_hash(committed))
if (committed == sha256::double_hash(
generate_merkle_root(true), reserved))
Expand Down
3 changes: 2 additions & 1 deletion src/chain/chain_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <algorithm>
#include <chrono>
#include <iterator>
#include <ranges>
#include <bitcoin/system/chain/block.hpp>
#include <bitcoin/system/chain/chain_state.hpp>
#include <bitcoin/system/chain/checkpoint.hpp>
Expand Down Expand Up @@ -451,7 +452,7 @@ uint32_t chain_state::easy_work_required(const data& values,
const auto& bits = values.bits.ordered;

// Reverse iterate the ordered-by-height list of header bits.
for (auto bit: views_reverse(bits))
for (auto bit: std::views::reverse(bits))
{
if (is_retarget_or_non_limit(--height, bit, retargeting_interval,
proof_of_work_limit))
Expand Down

0 comments on commit 574a62e

Please sign in to comment.