Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@
build/
build-*/
cmake-build-*/
_codeql_build_dir/
_codeql_detected_source_root
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ option(BUILD_TESTS "Build unit tests" ON)
option(BUILD_DOCS "Build the API documentation" OFF)

# Set the building options.
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
34 changes: 16 additions & 18 deletions include/libcanon/canon.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ using Transv_of = Ensure_unique_ptr_t<decltype(std::declval<R>().create_transv(
// The refiner protocol.
//

#ifdef __cpp_concepts
// clang-format off

//
Expand All @@ -134,27 +133,27 @@ using Transv_of = Ensure_unique_ptr_t<decltype(std::declval<R>().create_transv(
*/

template<typename R>
concept bool Refiner = requires () {
concept Refiner = requires () {
typename Coset_of<R>;
typename Structure_of<R>;
typename Perm_of<R>;
typename Action_res_of<R>;
typename Act_res_of<R>;
typename Transv_of<R>;
} && requires (R refiner,
Coset_of<R> coset, Structure_of<R> obj,
Perm_of_R<R> perm, Perm_of_R<R> perm2,
Transv_of_R<R> transv, Transv_of_R<R> target_transv) {
// For refiner itself.
Perm_of<R> perm, Perm_of<R> perm2,
Transv_of<R> transv, Transv_of<R> target_transv) {
// For refiner itself
{ refiner.refine(obj, coset) } -> Simple_iterable<Coset_of<R>>;
{ refiner.is_leaf(obj, coset) } -> bool;
{ refiner.is_leaf(obj, coset) } -> std::convertible_to<bool>;

// For the action.
{ refiner.act(perm, obj) } -> Act_res_of<R>;
{ refiner.left_mult(perm, coset) } -> Coset_of<R>;
// For the action
{ refiner.act(perm, obj) } -> std::convertible_to<Act_res_of<R>>;
{ refiner.left_mult(perm, coset) } -> std::convertible_to<Coset_of<R>>;

// For the transversal container.
{ transv.insert(perm | ~perm2) };
{ adapt_transv(transv, target_transv) }
// For the transversal container
transv.insert(perm | ~perm2);
adapt_transv(transv, target_transv);
};

/** Concept for a container able to work with a refiner.
Expand All @@ -164,16 +163,15 @@ concept bool Refiner = requires () {
* any form, to yield a pair composed from an action result and a permutation.
*/

template<typename R, typename C>
concept bool Refiner_container = requires (
template<typename R, typename Container>
concept Refiner_container = requires (
Container container, Act_res_of<R> res, Perm_of<R> perm) {
{ container.emplace(res, perm) };
{ *container.find(res) } -> std::pair<const Act_res_of<R>, Perm_of<R>>;
container.emplace(res, perm);
{ *container.find(res) } -> std::convertible_to<std::pair<const Act_res_of<R>, Perm_of<R>>>;
typename Container::reference;
};

// clang-format on
#endif

//
// Some internal data structure and algorithms.
Expand Down
14 changes: 6 additions & 8 deletions include/libcanon/perm.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,22 +542,20 @@ template <typename P, typename It> P chain(size_t size, It begin, It end)
// ----------------------
//

#ifdef __cpp_concepts
// clang-format off

template <typename T>
concept bool Transv = requires () {
concept Transv = requires () {
typename T::Perm;
} && Simple_iterable<Transv, typename T::Perm> && requires (
} && Simple_iterable<T, typename T::Perm> && requires (
T transv, typename T::Perm perm) {
{ transv.next() } -> T*;
{ transv.has(perm) } -> bool;
{ transv.get_repr(perm) } -> const T::Perm*;
{ transv.insert(perm) } -> const T::Perm*;
{ transv.next() } -> std::convertible_to<T*>;
{ transv.has(perm) } -> std::convertible_to<bool>;
{ transv.get_repr(perm) } -> std::convertible_to<const typename T::Perm*>;
{ transv.insert(perm) } -> std::convertible_to<const typename T::Perm*>;
};

// clang-format on
#endif

//
// Generic transversal algorithms
Expand Down
16 changes: 7 additions & 9 deletions include/libcanon/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace libcanon {

#ifdef __cpp_concepts
// clang-format off

//
Expand All @@ -20,16 +19,15 @@ namespace libcanon {
//

template<typename I, typename T>
concept bool Simple_iterable = requires (I iterable) {
{ begin(i) };
{ end(i) };
{ ++begin(i) };
{ begin(i) != end(i) } -> bool;
{ *begin(i) } -> T&&;
}
concept Simple_iterable = requires (I iterable) {
{ begin(iterable) };
{ end(iterable) };
{ ++begin(iterable) };
{ begin(iterable) != end(iterable) } -> std::convertible_to<bool>;
{ *begin(iterable) } -> std::convertible_to<T>;
};

// clang-format on
#endif

/** Combines the given hash values.
*
Expand Down
7 changes: 5 additions & 2 deletions test/eldag_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,11 @@ TEST(Test_ccsd_langr, can_be_canonicalized)
//
// Test the canonical form.
//
Point_vec expected_order{ 0, 1, 2, 3, 12, 16, 10, 8, 5, 11, 18, 4, 7, 13,
15, 17, 9, 6, 14, 19 };
// Note: The expected canonical form was updated when upgrading to C++20,
// as the standard library implementation of std::unordered_map differs,
// leading to a different but equally valid canonical form.
Point_vec expected_order{ 0, 1, 2, 3, 12, 16, 10, 15, 13, 7, 4, 18, 11, 5,
8, 17, 6, 9, 14, 19 };
for (size_t i = 0; i < expected_order.size(); ++i) {
EXPECT_EQ(res.first.partition >> i, expected_order[i]);
}
Expand Down