Skip to content

Commit 1c93f88

Browse files
committed
wip: alignment
1 parent f2e451a commit 1c93f88

6 files changed

Lines changed: 29 additions & 13 deletions

File tree

include/gl/topology/binary_tree.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "gl/constants.hpp"
88
#include "gl/conversion.hpp"
99
#include "gl/graph.hpp"
10-
#include "gl/util/pow.hpp"
10+
#include "gl/util/math.hpp"
1111

1212
#include <initializer_list>
1313

include/gl/util/ranges.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,16 @@ inline constexpr auto deref_view =
4141

4242
// TODO: add tests
4343

44-
/// @brief A generic view that concatenates two ranges/views.
45-
/// @todo Replace with `std::views::concat` (Requires C++26)
44+
/// @brief A view concatenating two ranges sequentially (C++20 polyfill for C++26 `std::views::concat`).
45+
///
46+
/// @warning **GCC 13/14 Bug:** Using branching views (like this or `std::ranges::filter_view`)
47+
/// inside complex algorithms (e.g., `std::ranges::is_permutation`) may trigger false-positive
48+
/// `-Wmaybe-uninitialized` warnings. To work around this, suppress the warning at the call site
49+
/// or materialize the view into a contiguous container like `std::vector`.
50+
///
51+
/// @tparam V1 First view type.
52+
/// @tparam V2 Second view type.
53+
/// @todo Replace with `std::views::concat` (C++26).
4654
template <std::ranges::view V1, std::ranges::view V2>
4755
class concat_view : public std::ranges::view_interface<concat_view<V1, V2>> {
4856
public:
@@ -179,8 +187,10 @@ struct concat_fn {
179187

180188
} // namespace detail
181189

182-
/// @brief Concatenates two ranges sequentially into a single view.
183-
/// @todo replace with `std::views::concat`
190+
/// @brief Concatenates two viewable ranges into a `concat_view`.
191+
/// @param r1 First range to concatenate.
192+
/// @param r2 Second range to concatenate.
193+
/// @todo Replace with `std::views::concat` (C++26).
184194
inline constexpr detail::concat_fn concat{};
185195

186196
} // namespace gl::util

tests/source/gl/test_util.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
#include <gl/util/pow.hpp>
1+
#include "doctest.h"
22

3-
#include <doctest.h>
3+
#include <gl/util/math.hpp>
4+
#include <gl/util/ranges.hpp>
5+
6+
#include <ranges>
7+
#include <vector>
48

59
namespace gl_testing {
610

tests/source/hgl/test_flat_incidence_list.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,9 +1231,10 @@ TEST_CASE_FIXTURE(
12311231
const auto [tail_bound_hyperedges, head_bound_hyperedges] =
12321232
altbind_to_vertex(sut, vertex_id, constants::n_hyperedges);
12331233

1234-
CHECK(std::ranges::is_permutation(
1235-
sut.incident_hyperedges(vertex_id), constants::hyperedge_ids_view
1236-
));
1234+
// NOTE: An explicit allocation is needed because of the GCC's false positive -Wmaybe-uninitialized warning
1235+
const auto incident_hyperedges =
1236+
sut.incident_hyperedges(vertex_id) | std::ranges::to<std::vector>();
1237+
CHECK(std::ranges::is_permutation(incident_hyperedges, constants::hyperedge_ids_view));
12371238
CHECK(std::ranges::equal(sut.out_hyperedges(vertex_id), tail_bound_hyperedges));
12381239
CHECK(std::ranges::equal(sut.in_hyperedges(vertex_id), head_bound_hyperedges));
12391240
}

tests/source/hgl/test_incidence_list.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,9 +1214,10 @@ TEST_CASE_FIXTURE(
12141214
const auto [tail_bound_hyperedges, head_bound_hyperedges] =
12151215
altbind_to_vertex(sut, vertex_id, constants::n_hyperedges);
12161216

1217-
CHECK(std::ranges::is_permutation(
1218-
sut.incident_hyperedges(vertex_id), constants::hyperedge_ids_view
1219-
));
1217+
// NOTE: An explicit allocation is needed because of the GCC's false positive -Wmaybe-uninitialized warning
1218+
const auto incident_hyperedges =
1219+
sut.incident_hyperedges(vertex_id) | std::ranges::to<std::vector>();
1220+
CHECK(std::ranges::is_permutation(incident_hyperedges, constants::hyperedge_ids_view));
12201221
CHECK(std::ranges::equal(sut.out_hyperedges(vertex_id), tail_bound_hyperedges));
12211222
CHECK(std::ranges::equal(sut.in_hyperedges(vertex_id), head_bound_hyperedges));
12221223
}

0 commit comments

Comments
 (0)