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..35e2689 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,12 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.15) 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/deps/fbitset b/deps/fbitset index c3ca474..765b2f7 160000 --- a/deps/fbitset +++ b/deps/fbitset @@ -1 +1 @@ -Subproject commit c3ca47404ac195a96f87ccf94ea66b3fc593cff5 +Subproject commit 765b2f740ca71e732d047aa65e067c1a9018feee diff --git a/include/libparenth.hpp b/include/libparenth.hpp index 7e6e5e8..f79bb2a 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{}; @@ -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()) { @@ -839,7 +841,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) {