Skip to content

Commit

Permalink
no_unique_address + empty struct for optional class memebers
Browse files Browse the repository at this point in the history
  • Loading branch information
fhamonic committed Jul 11, 2023
1 parent 5871bb6 commit 671791a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/melon/algorithm/breadth_first_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class breadth_first_search {
cursor _queue_current;

reached_map _reached_map;

[[no_unique_address]] pred_vertices_map _pred_vertices_map;
[[no_unique_address]] pred_arcs_map _pred_arcs_map;
[[no_unique_address]] distances_map _dist_map;
Expand Down
1 change: 1 addition & 0 deletions include/melon/algorithm/depth_first_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class depth_first_search {
std::vector<vertex> _stack;

reached_map _reached_map;

[[no_unique_address]] pred_vertices_map _pred_vertices_map;
[[no_unique_address]] pred_arcs_map _pred_arcs_map;
[[no_unique_address]] distances_map _dist_map;
Expand Down
1 change: 1 addition & 0 deletions include/melon/algorithm/dijkstra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class dijkstra {

heap _heap;
vertex_status_map _vertex_status_map;

[[no_unique_address]] pred_vertices_map _pred_vertices_map;
[[no_unique_address]] pred_arcs_map _pred_arcs_map;
[[no_unique_address]] distances_map _distances_map;
Expand Down
16 changes: 10 additions & 6 deletions include/melon/algorithm/topological_sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ class topological_sort {

using reached_map = vertex_map_t<G, bool>;
using remaining_in_degree_map = vertex_map_t<G, long unsigned int>;
struct no_pred_vertices_map {};
using pred_vertices_map =
std::conditional<traits::store_pred_vertices, vertex_map_t<G, vertex>,
std::monostate>::type;
no_pred_vertices_map>::type;
struct no_pred_arcs_map {};
using pred_arcs_map =
std::conditional<traits::store_pred_arcs, vertex_map_t<G, arc>,
std::monostate>::type;
no_pred_arcs_map>::type;
struct no_distance_map {};
using distances_map =
std::conditional<traits::store_distances, vertex_map_t<G, int>,
std::monostate>::type;
no_distance_map>::type;

private:
std::reference_wrapper<const G> _graph;
Expand All @@ -53,6 +56,7 @@ class topological_sort {

reached_map _reached_map;
remaining_in_degree_map _remaining_in_degree_map;

[[no_unique_address]] pred_vertices_map _pred_vertices_map;
[[no_unique_address]] pred_arcs_map _pred_arcs_map;
[[no_unique_address]] distances_map _dist_map;
Expand Down Expand Up @@ -93,11 +97,11 @@ class topological_sort {
, _remaining_in_degree_map(create_vertex_map<long unsigned int>(
g, std::numeric_limits<unsigned int>::max()))
, _pred_vertices_map(constexpr_ternary<traits::store_pred_vertices>(
create_vertex_map<vertex>(g), std::monostate{}))
create_vertex_map<vertex>(g), no_pred_vertices_map{}))
, _pred_arcs_map(constexpr_ternary<traits::store_pred_arcs>(
create_vertex_map<arc>(g), std::monostate{}))
create_vertex_map<arc>(g), no_pred_arcs_map{}))
, _dist_map(constexpr_ternary<traits::store_distances>(
create_vertex_map<int>(g), std::monostate{})) {
create_vertex_map<int>(g), no_distance_map{})) {
_queue.reserve(nb_vertices(g));
push_start_vertices();
}
Expand Down

0 comments on commit 671791a

Please sign in to comment.