Sequoia
Loading...
Searching...
No Matches
StaticNodeStorage.hpp
Go to the documentation of this file.
1
2// Copyright Oliver J. Rosten 2018. //
3// Distributed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. //
4// (See accompanying file LICENSE.md or copy at //
5// https://www.gnu.org/licenses/gpl-3.0.en.html) //
7
8#pragma once
9
17
18namespace sequoia::maths
19{
20 template
21 <
22 class Weight,
23 std::size_t N
24 >
25 class static_node_storage : public node_storage_base<Weight, std::array<Weight, N>>
26 {
28 public:
29 using size_type = typename base_t::size_type;
30 using weight_type = typename base_t::weight_type;
31
32 constexpr static_node_storage() = default;
33
34 constexpr static_node_storage(const size_type)
35 : base_t{}
36 {}
37
38 constexpr static_node_storage(std::initializer_list<weight_type> weights)
39 : base_t{utilities::to_array<weight_type, N>(weights, std::identity{})}
40 {}
41
42 constexpr static_node_storage(const static_node_storage&) = default;
43 constexpr static_node_storage& operator=(const static_node_storage&) = default;
44 protected:
45 constexpr static_node_storage(static_node_storage&&) noexcept = default;
46 constexpr static_node_storage& operator=(static_node_storage&&) noexcept = default;
47
48 ~static_node_storage() = default;
49 };
50
51 template<class Weight, std::size_t N>
52 requires std::is_empty_v<Weight>
53 class static_node_storage<Weight, N>
54 {
55 public:
56 using weight_type = Weight;
57 using size_type = std::size_t;
58
59 constexpr static_node_storage() = default;
60 constexpr static_node_storage(const std::size_t) {}
61
62 [[nodiscard]]
63 constexpr friend bool operator==(const static_node_storage&, const static_node_storage&) noexcept = default;
64
65 [[nodiscard]]
66 constexpr static std::size_t size() noexcept { return N; }
67
68 constexpr static_node_storage(const static_node_storage&) = default;
69 constexpr static_node_storage& operator=(const static_node_storage&) = default;
70 protected:
71 constexpr static_node_storage(static_node_storage&&) noexcept = default;
72 constexpr static_node_storage& operator=(static_node_storage&&) noexcept = default;
73
74 ~static_node_storage() = default;
75 };
76}
Utility to convert an initializer_list into an array, potentially transforming the initializer_list i...
Classes to allow homogeneous treatment of graphs with empty/non-empty node weights.
Definition: NodeStorage.hpp:37
Definition: StaticNodeStorage.hpp:26