Skip to content

Commit 01d191d

Browse files
committed
.clangd
1 parent c485bbe commit 01d191d

4 files changed

Lines changed: 70 additions & 30 deletions

File tree

.clangd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
CompileFlags:
2+
Add:
3+
- -std=c++23
4+
- -xc++-header
5+
- -Iinclude
6+
- -Itests/include
7+
- -Itests/external
8+
- -Wall
9+
- -Wextra
10+
- -ftemplate-depth=512
11+
12+
Diagnostics:
13+
UnusedIncludes: None
14+
ClangTidy:
15+
Add:
16+
- bugprone-*
17+
- modernize-*
18+
- performance-*
19+
Remove:
20+
- modernize-use-trailing-return-type
21+
22+
Index:
23+
Background: Build

include/hgl/hypergraph.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class hypergraph final {
5252
if constexpr (type_traits::c_non_empty_properties<hyperedge_properties_type>) {
5353
this->_hyperedge_properties.reserve(n_hyperedges);
5454
for (const auto _ : this->hyperedge_ids())
55-
this->_hyperedge_properties.push_back(std::make_unique<hyperedge_properties_type>()
55+
this->_hyperedge_properties.push_back(
56+
std::make_unique<hyperedge_properties_type>()
5657
);
5758
}
5859
}
@@ -257,7 +258,8 @@ class hypergraph final {
257258
const auto old_size = this->_hyperedge_properties.size();
258259
this->_hyperedge_properties.reserve(this->_n_hyperedges);
259260
for (types::size_type i = old_size; i < this->_n_hyperedges; ++i)
260-
this->_hyperedge_properties.push_back(std::make_unique<hyperedge_properties_type>()
261+
this->_hyperedge_properties.push_back(
262+
std::make_unique<hyperedge_properties_type>()
261263
);
262264
}
263265
}

include/hgl/impl/incidence_list.hpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "hgl/types/types.hpp"
1010

1111
#include <algorithm>
12+
#include <cstddef>
1213
#include <ranges>
1314
#include <vector>
1415

@@ -57,15 +58,17 @@ class incidence_list<hgl::undirected_t, LayoutTag> final {
5758
this->_remove_minor(vertex_id);
5859
}
5960

60-
[[nodiscard]] gl_attr_force_inline auto incident_hyperedges(const types::id_type vertex_id
61+
[[nodiscard]] gl_attr_force_inline auto incident_hyperedges(
62+
const types::id_type vertex_id
6163
) const noexcept {
6264
if constexpr (std::same_as<layout_tag, impl::vertex_major_t>)
6365
return this->_incident_with_major(vertex_id);
6466
else
6567
return this->_incident_with_minor(vertex_id);
6668
}
6769

68-
[[nodiscard]] gl_attr_force_inline types::size_type degree(const types::id_type vertex_id
70+
[[nodiscard]] gl_attr_force_inline types::size_type degree(
71+
const types::id_type vertex_id
6972
) const noexcept {
7073
if constexpr (std::same_as<layout_tag, impl::vertex_major_t>)
7174
return this->_major_size(vertex_id);
@@ -87,7 +90,8 @@ class incidence_list<hgl::undirected_t, LayoutTag> final {
8790
this->_remove_minor(hyperedge_id);
8891
}
8992

90-
[[nodiscard]] gl_attr_force_inline auto incident_vertices(const types::id_type hyperedge_id
93+
[[nodiscard]] gl_attr_force_inline auto incident_vertices(
94+
const types::id_type hyperedge_id
9195
) const noexcept {
9296
if constexpr (std::same_as<layout_tag, impl::hyperedge_major_t>)
9397
return this->_incident_with_major(hyperedge_id);
@@ -142,7 +146,9 @@ class incidence_list<hgl::undirected_t, LayoutTag> final {
142146
using major_storage_type = std::vector<major_element_type>;
143147

144148
gl_attr_force_inline void _remove_major(const types::id_type major_id) noexcept {
145-
this->_major_storage.erase(this->_major_storage.begin() + major_id);
149+
this->_major_storage.erase(
150+
this->_major_storage.begin() + static_cast<std::ptrdiff_t>(major_id)
151+
);
146152
}
147153

148154
void _remove_minor(const types::id_type minor_id) noexcept {
@@ -155,20 +161,23 @@ class incidence_list<hgl::undirected_t, LayoutTag> final {
155161
}
156162
}
157163

158-
[[nodiscard]] gl_attr_force_inline auto _incident_with_major(const types::id_type major_id
164+
[[nodiscard]] gl_attr_force_inline auto _incident_with_major(
165+
const types::id_type major_id
159166
) const noexcept {
160167
return std::views::all(this->_major_storage[major_id]);
161168
}
162169

163-
[[nodiscard]] gl_attr_force_inline auto _incident_with_minor(const types::id_type minor_id
170+
[[nodiscard]] gl_attr_force_inline auto _incident_with_minor(
171+
const types::id_type minor_id
164172
) const noexcept {
165173
return std::views::iota(0uz, this->_major_storage.size())
166174
| std::views::filter([this, minor_id](types::id_type major_id) {
167175
return this->_are_bound_impl(this->_major_storage[major_id], minor_id);
168176
});
169177
}
170178

171-
[[nodiscard]] gl_attr_force_inline types::size_type _major_size(const types::id_type major_id
179+
[[nodiscard]] gl_attr_force_inline types::size_type _major_size(
180+
const types::id_type major_id
172181
) const noexcept {
173182
return this->_major_storage[major_id].size();
174183
}
@@ -181,6 +190,7 @@ class incidence_list<hgl::undirected_t, LayoutTag> final {
181190
return size;
182191
}
183192

193+
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
184194
void _bind_impl(const types::id_type major_id, const types::id_type minor_id) noexcept {
185195
auto& minor_storage = this->_major_storage[major_id];
186196

@@ -191,7 +201,9 @@ class incidence_list<hgl::undirected_t, LayoutTag> final {
191201
}
192202

193203
gl_attr_force_inline void _unbind_impl(
194-
const types::id_type major_id, const types::id_type minor_id
204+
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
205+
const types::id_type major_id,
206+
const types::id_type minor_id
195207
) noexcept {
196208
auto& minor_storage = this->_major_storage[major_id];
197209
const auto minor_it = std::ranges::lower_bound(minor_storage, minor_id);

include/hgl/impl/incidence_matrix.hpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
#include "hgl/types/types.hpp"
1010

1111
#include <algorithm>
12+
#include <cstddef>
13+
#include <cstdint>
1214
#include <ranges>
1315
#include <vector>
14-
#include <cstdint>
1516

1617
#ifdef HGL_TESTING
1718
namespace hgl_testing {
@@ -63,7 +64,8 @@ class incidence_matrix<hgl::undirected_t, LayoutTag> final {
6364
this->_remove_minor(vertex_id);
6465
}
6566

66-
[[nodiscard]] gl_attr_force_inline auto incident_hyperedges(const types::id_type vertex_id
67+
[[nodiscard]] gl_attr_force_inline auto incident_hyperedges(
68+
const types::id_type vertex_id
6769
) const noexcept {
6870
if constexpr (std::same_as<layout_tag, impl::vertex_major_t>)
6971
return this->_incident_with_major(vertex_id);
@@ -94,16 +96,16 @@ class incidence_matrix<hgl::undirected_t, LayoutTag> final {
9496
this->_remove_minor(hyperedge_id);
9597
}
9698

97-
[[nodiscard]] gl_attr_force_inline auto incident_vertices(const types::id_type hyperedge_id
99+
[[nodiscard]] gl_attr_force_inline auto incident_vertices(
100+
const types::id_type hyperedge_id
98101
) const noexcept {
99102
if constexpr (std::same_as<layout_tag, impl::hyperedge_major_t>)
100103
return this->_incident_with_major(hyperedge_id);
101104
else
102105
return this->_incident_with_minor(hyperedge_id);
103106
}
104107

105-
[[nodiscard]] types::size_type hyperedge_size(const types::id_type hyperedge_id
106-
) const noexcept {
108+
[[nodiscard]] types::size_type hyperedge_size(const types::id_type hyperedge_id) const noexcept {
107109
if constexpr (std::same_as<layout_tag, impl::hyperedge_major_t>)
108110
return this->_count_major(hyperedge_id);
109111
else
@@ -154,15 +156,15 @@ class incidence_matrix<hgl::undirected_t, LayoutTag> final {
154156
}
155157

156158
gl_attr_force_inline void _remove_major(const types::id_type major_id) noexcept {
157-
this->_matrix.erase(this->_matrix.begin() + major_id);
159+
this->_matrix.erase(this->_matrix.begin() + static_cast<std::ptrdiff_t>(major_id));
158160
}
159161

160162
gl_attr_force_inline void _remove_minor(const types::id_type minor_id) noexcept {
161163
if (this->_matrix_row_size == 0)
162164
return;
163165
this->_matrix_row_size--;
164166
for (auto& row : this->_matrix) {
165-
row.erase(row.begin() + minor_id);
167+
row.erase(row.begin() + static_cast<std::ptrdiff_t>(minor_id));
166168
}
167169
}
168170

@@ -211,7 +213,8 @@ class incidence_matrix<hgl::bf_directed_t, LayoutTag> final {
211213
incidence_matrix(const types::size_type n_vertices, const types::size_type n_hyperedges)
212214
: _matrix_row_size{layout_tag::minor(n_vertices, n_hyperedges)},
213215
_matrix(
214-
layout_tag::major(n_vertices, n_hyperedges), matrix_row_type(_matrix_row_size, incidence_type::none)
216+
layout_tag::major(n_vertices, n_hyperedges),
217+
matrix_row_type(_matrix_row_size, incidence_type::none)
215218
) {}
216219

217220
incidence_matrix(incidence_matrix&&) = default;
@@ -235,7 +238,8 @@ class incidence_matrix<hgl::bf_directed_t, LayoutTag> final {
235238
this->_remove_minor(vertex_id);
236239
}
237240

238-
[[nodiscard]] gl_attr_force_inline auto incident_hyperedges(const types::id_type vertex_id
241+
[[nodiscard]] gl_attr_force_inline auto incident_hyperedges(
242+
const types::id_type vertex_id
239243
) const noexcept {
240244
if constexpr (std::same_as<layout_tag, impl::vertex_major_t>)
241245
return this->_incident_with_major(vertex_id);
@@ -268,16 +272,16 @@ class incidence_matrix<hgl::bf_directed_t, LayoutTag> final {
268272
this->_remove_minor(hyperedge_id);
269273
}
270274

271-
[[nodiscard]] gl_attr_force_inline auto incident_vertices(const types::id_type hyperedge_id
275+
[[nodiscard]] gl_attr_force_inline auto incident_vertices(
276+
const types::id_type hyperedge_id
272277
) const noexcept {
273278
if constexpr (std::same_as<layout_tag, impl::hyperedge_major_t>)
274279
return this->_incident_with_major(hyperedge_id);
275280
else
276281
return this->_incident_with_minor(hyperedge_id);
277282
}
278283

279-
[[nodiscard]] types::size_type hyperedge_size(const types::id_type hyperedge_id
280-
) const noexcept {
284+
[[nodiscard]] types::size_type hyperedge_size(const types::id_type hyperedge_id) const noexcept {
281285
if constexpr (std::same_as<layout_tag, impl::hyperedge_major_t>)
282286
return this->_count_major(hyperedge_id);
283287
else
@@ -317,15 +321,14 @@ class incidence_matrix<hgl::bf_directed_t, LayoutTag> final {
317321

318322
private:
319323
enum class incidence_type : std::int8_t {
320-
none = 0, // v not in E
324+
none = 0, // v not in E
321325
backward = -1, // v in T(E)
322-
forward = 1, // v in H(E)
326+
forward = 1, // v in H(E)
323327
};
324328

325-
template <typename P>
326-
concept c_incidence_pred = std::predicate<P, incidence_type>;
327-
328-
static constexpr auto _are_incident_pred = [](const incidence_type t) { return t != incidence_type::none; };
329+
static constexpr auto _are_incident_pred = [](const incidence_type t) {
330+
return t != incidence_type::none;
331+
};
329332

330333
using matrix_row_type = std::vector<incidence_type>;
331334
using hypergraph_storage_type = std::vector<matrix_row_type>;
@@ -370,7 +373,7 @@ class incidence_matrix<hgl::bf_directed_t, LayoutTag> final {
370373

371374
[[nodiscard]] types::size_type _count_major(
372375
const types::id_type major_id,
373-
const c_incidence_pred auto pred = incidence_matrix::_are_incident_pred
376+
const std::predicate<incidence_type> auto pred = incidence_matrix::_are_incident_pred
374377
) const noexcept {
375378
types::size_type count = 0;
376379
for (const incidence_type t : this->_matrix[major_id])
@@ -380,7 +383,7 @@ class incidence_matrix<hgl::bf_directed_t, LayoutTag> final {
380383

381384
[[nodiscard]] types::size_type _count_minor(
382385
const types::id_type minor_id,
383-
const c_incidence_pred auto pred = incidence_matrix::_are_incident_pred
386+
const std::predicate<incidence_type> auto pred = incidence_matrix::_are_incident_pred
384387
) const noexcept {
385388
types::size_type count = 0;
386389
for (const auto& row : this->_matrix)

0 commit comments

Comments
 (0)