Skip to content

Migrate to C++20 for fbitset compatibility#5

Merged
chenpeizhi merged 5 commits intomasterfrom
copilot/update-libparenth-to-cpp20
Nov 10, 2025
Merged

Migrate to C++20 for fbitset compatibility#5
chenpeizhi merged 5 commits intomasterfrom
copilot/update-libparenth-to-cpp20

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

The fbitset dependency migrated to C++20, replacing GCC builtins with std::bit library functions (std::countl_zero, std::countr_zero, std::popcount). This updates libparenth accordingly.

Changes

  • Build configuration: C++20 standard, CMake 3.12+ requirement, CMAKE_CXX_STANDARD_REQUIRED ON
  • fbitset submodule: Updated to commit 765b2f7 (C++20 version)
  • Code quality: Added [[nodiscard]] to API functions (opt(), n_dims(), n_factors(), get_tot())
  • Documentation: Clarified find_last() behavior with unsigned overflow semantics

Compatibility Note

The updated fbitset find_last() returns SIZE_MAX (not -1) when no bits are set. Existing code handles this correctly via well-defined unsigned wrap-around:

auto top_idx = bsums.curr_sums.find_last();  // SIZE_MAX when count() == 0
auto next_idx = top_idx + 1;                  // Wraps to 0 (well-defined)

No algorithmic changes required. All tests pass.

Original prompt

The dependency fbitset has been updated to use C++20 features. Check compatibility and update libparenth. You may want to rethink d0afb59 and how to properly fix previous compatibility issues. Update to C++20, and review and improve the codebase, without compromising performance and correctness.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 10, 2025 05:16
Co-authored-by: chenpeizhi <8114085+chenpeizhi@users.noreply.github.com>
Co-authored-by: chenpeizhi <8114085+chenpeizhi@users.noreply.github.com>
Co-authored-by: chenpeizhi <8114085+chenpeizhi@users.noreply.github.com>
Copilot AI changed the title [WIP] Update libparenth for C++20 compatibility with fbitset Migrate to C++20 for fbitset compatibility Nov 10, 2025
Copilot AI requested a review from chenpeizhi November 10, 2025 05:32
@chenpeizhi chenpeizhi marked this pull request as ready for review November 10, 2025 07:05
Copilot AI review requested due to automatic review settings November 10, 2025 07:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates libparenth to C++20 to maintain compatibility with the updated fbitset dependency, which now uses std::bit library functions instead of GCC builtins.

Key Changes:

  • Updated build configuration to C++20 standard with CMake 3.15+ requirement
  • Updated fbitset submodule to C++20-compatible version (commit 765b2f7)
  • Added [[nodiscard]] attributes to query functions for better code safety

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
CMakeLists.txt Updated CMake minimum version to 3.15, set C++20 standard, and enforced standard requirement
.clang-format Updated standard specification from Cpp11 to c++20
include/libparenth.hpp Added [[nodiscard]] attributes to API functions and documented unsigned overflow behavior in find_last() usage
deps/fbitset Updated submodule to C++20-compatible version (765b2f7)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chenpeizhi chenpeizhi merged commit a1e4899 into master Nov 10, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants