Skip to content

Commit 79d02b3

Browse files
committed
std=c++23
Signed-off-by: Elazar Gershuni <[email protected]>
1 parent 0d88399 commit 79d02b3

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
4242
find_package(yaml-cpp REQUIRED)
4343
endif ()
4444
find_package(Boost REQUIRED)
45-
set(CMAKE_CXX_STANDARD 20)
45+
set(CMAKE_CXX_STANDARD 23)
4646
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4747
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
4848
list(APPEND CMAKE_CONFIGURATION_TYPES FuzzerDebug)
@@ -128,7 +128,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
128128

129129
set(SANITIZE_FLAGS -fsanitize=address -O1 -fno-omit-frame-pointer)
130130
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
131-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20")
131+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++23")
132132
endif ()
133133

134134
add_library(ebpfverifier ${LIB_SRC})

src/crab_utils/adapt_sgraph.hpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33
#pragma once
44

5-
#include <memory>
6-
75
#include <boost/container/flat_map.hpp>
86

97
#include "crab_utils/num_safeint.hpp"
@@ -31,11 +29,11 @@ class TreeSMap final {
3129
key_iter_t() = default;
3230
explicit key_iter_t(const col::const_iterator& _e) : e(_e) {}
3331

34-
// XXX: to make sure that we always return the same address
35-
// for the "empty" iterator, otherwise we can trigger
36-
// undefined behavior.
37-
inline static std::unique_ptr<key_iter_t> _empty_iter = std::make_unique<key_iter_t>();
38-
static key_iter_t empty_iterator() { return *_empty_iter; }
32+
/// return canonical empty iterator
33+
static key_iter_t empty_iterator() {
34+
static key_iter_t empty_iter;
35+
return empty_iter;
36+
}
3937

4038
key_t operator*() const { return e->first; }
4139
bool operator!=(const key_iter_t& o) const { return e != o.e; }
@@ -142,8 +140,6 @@ class TreeSMap final {
142140

143141
// Adaptive sparse-set based weighted graph implementation
144142
class AdaptGraph final {
145-
using smap_t = TreeSMap;
146-
147143
public:
148144
/** DBM weights (Weight) can be represented using one of the following
149145
* types:
@@ -233,19 +229,19 @@ class AdaptGraph final {
233229
Weight val;
234230
};
235231

236-
smap_t::elt_iter_t it{};
232+
TreeSMap::elt_iter_t it{};
237233
const std::vector<Weight>* ws{};
238234

239-
edge_const_iter(const smap_t::elt_iter_t& _it, const std::vector<Weight>& _ws) : it(_it), ws(&_ws) {}
235+
edge_const_iter(const TreeSMap::elt_iter_t& _it, const std::vector<Weight>& _ws) : it(_it), ws(&_ws) {}
240236
edge_const_iter(const edge_const_iter& o) = default;
241237
edge_const_iter& operator=(const edge_const_iter& o) = default;
242238
edge_const_iter() = default;
243239

244-
// XXX: to make sure that we always return the same address
245-
// for the "empty" iterator, otherwise we can trigger
246-
// undefined behavior.
247-
inline static std::unique_ptr<edge_const_iter> _empty_iter = std::make_unique<edge_const_iter>();
248-
static edge_const_iter empty_iterator() { return *_empty_iter; }
240+
/// return canonical empty iterator
241+
static edge_const_iter empty_iterator() {
242+
static edge_const_iter empty_iter;
243+
return empty_iter;
244+
}
249245

250246
edge_ref operator*() const { return edge_ref{it->first, (*ws)[it->second]}; }
251247
edge_const_iter operator++() {
@@ -256,7 +252,7 @@ class AdaptGraph final {
256252
};
257253

258254
struct edge_const_range_t {
259-
using elt_range_t = smap_t::elt_range_t;
255+
using elt_range_t = TreeSMap::elt_range_t;
260256
using iterator = edge_const_iter;
261257

262258
elt_range_t r;
@@ -279,8 +275,8 @@ class AdaptGraph final {
279275
using fwd_edge_const_iter = edge_const_iter;
280276
using rev_edge_const_iter = edge_const_iter;
281277

282-
using adj_range_t = smap_t::key_const_range_t;
283-
using adj_const_range_t = smap_t::key_const_range_t;
278+
using adj_range_t = TreeSMap::key_const_range_t;
279+
using adj_const_range_t = TreeSMap::key_const_range_t;
284280
using neighbour_range = adj_range_t;
285281
using neighbour_const_range = adj_const_range_t;
286282

@@ -357,7 +353,7 @@ class AdaptGraph final {
357353
edge_count -= _succs[v].size();
358354
_succs[v].clear();
359355

360-
for (smap_t::key_t k : _preds[v].keys()) {
356+
for (TreeSMap::key_t k : _preds[v].keys()) {
361357
_succs[k].remove(v);
362358
}
363359
edge_count -= _preds[v].size();
@@ -492,8 +488,8 @@ class AdaptGraph final {
492488

493489
// Ick. This'll have another indirection on every operation.
494490
// We'll see what the performance costs are like.
495-
std::vector<smap_t> _preds{};
496-
std::vector<smap_t> _succs{};
491+
std::vector<TreeSMap> _preds{};
492+
std::vector<TreeSMap> _succs{};
497493
std::vector<Weight> _ws{};
498494

499495
size_t edge_count{};

0 commit comments

Comments
 (0)