From ba224dcf1543b1208b3f1014e4bf2ea96c44c07a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 05:12:02 +0000 Subject: [PATCH 1/5] Initial plan From fb004906d4c5cc5f3ad0b03effe2586b27b01ddc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 05:16:22 +0000 Subject: [PATCH 2/5] Initial plan for C++20 upgrade Co-authored-by: chenpeizhi <8114085+chenpeizhi@users.noreply.github.com> --- deps/fbitset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/fbitset b/deps/fbitset index c3ca474..765b2f7 160000 --- a/deps/fbitset +++ b/deps/fbitset @@ -1 +1 @@ -Subproject commit c3ca47404ac195a96f87ccf94ea66b3fc593cff5 +Subproject commit 765b2f740ca71e732d047aa65e067c1a9018feee From 0397545c7ea15f0c575a7f525ed1efe1321de5dc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 05:23:59 +0000 Subject: [PATCH 3/5] Update to C++20 and add nodiscard attributes Co-authored-by: chenpeizhi <8114085+chenpeizhi@users.noreply.github.com> --- .clang-format | 2 +- CMakeLists.txt | 5 +++-- include/libparenth.hpp | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.clang-format b/.clang-format index b1dc370..59e48d1 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,7 @@ --- Language: Cpp BasedOnStyle: WebKit -Standard: Cpp11 +Standard: c++20 ColumnLimit: 80 ... diff --git a/CMakeLists.txt b/CMakeLists.txt index 35c790c..b7ec966 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,12 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.12) project(libparenth VERSION 0.1.0 LANGUAGES CXX) # OPTIONS option(BUILD_TESTS "Build unit tests" ON) # Set the building options. -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) include_directories( "${PROJECT_SOURCE_DIR}/include" diff --git a/include/libparenth.hpp b/include/libparenth.hpp index 7e6e5e8..72122c9 100644 --- a/include/libparenth.hpp +++ b/include/libparenth.hpp @@ -125,12 +125,12 @@ class Parenther { /** The total number of summation and external indices. */ - size_t n_dims() const noexcept { return dims_.size(); } + [[nodiscard]] size_t n_dims() const noexcept { return dims_.size(); } /** The total number of factors. */ - size_t n_factors() const noexcept { return dims_on_.size(); } + [[nodiscard]] size_t n_factors() const noexcept { return dims_on_.size(); } /** The two operands of a pairwise contraction. * @@ -218,7 +218,7 @@ class Parenther { * the traversed subproblems can be found, are returned. */ - Mem opt(Mode mode, bool if_incl) + [[nodiscard]] Mem opt(Mode mode, bool if_incl) { Mem mem{}; @@ -839,7 +839,7 @@ class Parenther { * zero). */ - Dim get_tot(const Dim_subset& dims) const noexcept + [[nodiscard]] Dim get_tot(const Dim_subset& dims) const noexcept { Dim res{ 1l }; for (auto it = dims.begin(); it; ++it) { From b542ba148fc1596b73d5b299ee19fcc94a0fdeb7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 05:25:14 +0000 Subject: [PATCH 4/5] Add clarifying comment about find_last behavior Co-authored-by: chenpeizhi <8114085+chenpeizhi@users.noreply.github.com> --- include/libparenth.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/libparenth.hpp b/include/libparenth.hpp index 72122c9..f79bb2a 100644 --- a/include/libparenth.hpp +++ b/include/libparenth.hpp @@ -331,6 +331,8 @@ class Parenther { auto has_top_idx = bsums.curr_sums.count() > 0; auto top_idx = bsums.curr_sums.find_last(); + // Note: When count() == 0, find_last() returns SIZE_MAX. + // next_idx wraps to 0 via unsigned overflow, which is well-defined. auto next_idx = top_idx + 1; if (next_idx < sums_.size()) { From a0ec058a6899d1b50037ea05f68645f0b68e14f0 Mon Sep 17 00:00:00 2001 From: Guo Chen Date: Mon, 10 Nov 2025 00:59:21 -0600 Subject: [PATCH 5/5] Update to CMake 3.15 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7ec966..35e2689 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.15) project(libparenth VERSION 0.1.0 LANGUAGES CXX) # OPTIONS