script: Default script_verify_flags comparisons #34122

pull Brotcrunsher wants to merge 1 commits into bitcoin:master from Brotcrunsher:verify_flags_simplification changing 1 files +1 −7
  1. Brotcrunsher commented at 8:50 PM on December 19, 2025: contributor

    Replace the manual operator== and friend operator<=> in src/script/verify_flags.h with a defaulted member operator<=>.

    This reduces boilerplate while preserving the existing semantics (m_value comparison) and continues to provide ==, <, >, <=, and >= via the compiler-generated comparison operators.

    Note: This is a small refactor, but it removes duplicated comparison logic and reduces the chance of == and <=> diverging in future edits. If that’s not considered worthwhile, I can close/drop it.

  2. DrahtBot added the label Consensus on Dec 19, 2025
  3. DrahtBot commented at 8:50 PM on December 19, 2025: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34122.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK billymcbip

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. in src/script/verify_flags.h:49 in d33b770310
      51 | -    /** Compare two script_verify_flags. <, >, <=, and >= are auto-generated from this. */
      52 | -    friend constexpr std::strong_ordering operator<=>(const script_verify_flags& a, const script_verify_flags& b) noexcept
      53 | -    {
      54 | -        return a.m_value <=> b.m_value;
      55 | -    }
      56 | +    constexpr auto operator<=>(const script_verify_flags& other) const = default;
    


    billymcbip commented at 3:19 PM on December 27, 2025:

    Can you use std::strong_ordering instead of auto?

    I'm getting a Included header compare is not used directly lint warning for #include <compare> when using auto.


    Brotcrunsher commented at 8:30 PM on January 1, 2026:

    Done!

  5. script: Default script_verify_flags comparisons
    Replace the manual operator== and friend operator<=> in src/script/verify_flags.h
    with a defaulted member operator<=>.
    
    This reduces boilerplate while preserving the existing semantics (m_value
    comparison) and continues to provide ==, <, >, <=, and >= via the
    compiler-generated comparison operators.
    eaf2f07e42
  6. Brotcrunsher force-pushed on Jan 1, 2026
  7. billymcbip commented at 11:59 AM on January 2, 2026: contributor

    tACK eaf2f07e42ac3574ea4b1b2fc9a5d11d3ab6ded2

  8. sedited commented at 12:51 PM on February 9, 2026: contributor

    I'm not convinced that this is worthwhile. For such a tiny refactor it has also not attracted much review over the past month. I think we can switch to a defaulted space ship operator when there is a need for it.

  9. maflcko commented at 12:56 PM on February 9, 2026: member

    Closing for now. Looks like this may be controversial.

  10. maflcko closed this on Feb 9, 2026


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-26 03:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me