18#ifndef LIVE_CELLS_KEYS_HPP
19#define LIVE_CELLS_KEYS_HPP
35 virtual ~key()
noexcept =
default;
44 virtual bool eq(
const key &
k)
const noexcept = 0;
86 template <
typename T,
typename...
Args>
89 std::static_pointer_cast<const key>(
90 std::make_shared<T>(
args...)
117 std::shared_ptr<const key> key_;
119 key_ref(std::shared_ptr<const key> ref) : key_(ref) {}
130 bool eq(
const key &
k)
const noexcept override;
132 std::size_t
hash()
const noexcept override;
146 template <
typename T,
typename... Ts>
175 if (
key ==
nullptr) {
179 const auto &
t1 =
typeid(*this);
180 const auto &
t2 =
typeid(
other);
182 return t1 ==
t2 && values_equal(*
key);
186 return internal::hash_combine(0,
typeid(*this).hash_code(), hash_values());
199 return value ==
key.value && rest.values_equal(
key.rest);
207 std::size_t hash_values() const noexcept {
208 return internal::hash_combine(0, value, rest.hash_values());
219 template <
typename T>
238 if (
key ==
nullptr) {
242 const auto &
t1 =
typeid(*this);
243 const auto &
t2 =
typeid(
other);
245 return t1 ==
t2 && values_equal(*
key);
249 return internal::hash_combine(0,
typeid(*this).hash_code(), hash_values());
257 std::size_t hash_values() const noexcept {
258 return std::hash<T>{}(
value);
261 template <
typename T1,
typename... Ts>
265 inline bool operator ==(
const key &k1,
const key &k2) {
269 inline bool operator !=(
const key &k1,
const key &k2) {
273 inline bool operator ==(
const key_ref &k1,
const key_ref &k2) {
277 inline bool operator !=(
const key_ref &k1,
const key_ref &k2) {
A computed cell which determines its argument cells at runtime.
Definition dynamic_compute_cell.hpp:153
Dynamically type key container.
Definition keys.hpp:76
static key_ref create(Args... args)
Create a key_ref holding a key of type T.
Definition keys.hpp:87
const key * operator->() const
Definition keys.hpp:109
const key & operator*() const
Definition keys.hpp:100
Defines the interface for a key which uniquely identifies a cell.
Definition keys.hpp:33
virtual bool is_unique() const noexcept
Is this a unique key?
Definition keys.hpp:61
virtual bool eq(const key &k) const noexcept=0
Compare this key to another key for equality.
virtual std::size_t hash() const noexcept=0
Compute the hash code for this key.
A key of uniquely identified by a single instance.
Definition keys.hpp:128
std::size_t hash() const noexcept override
Compute the hash code for this key.
Definition live_cells.cpp:33
bool eq(const key &k) const noexcept override
Compare this key to another key for equality.
Definition live_cells.cpp:29
bool is_unique() const noexcept override
Is this a unique key?
Definition keys.hpp:134
bool eq(const key &other) const noexcept override
Compare this key to another key for equality.
Definition keys.hpp:235
std::size_t hash() const noexcept override
Compute the hash code for this key.
Definition keys.hpp:248
value_key(T value)
Create a key distinguished from other keys by one value.
Definition keys.hpp:232
Base class for a key distinguished from other keys by one or more values.
Definition keys.hpp:147
value_key(T value, Ts... rest)
Create a key distinguished from other keys by one or more values.
Definition keys.hpp:167
std::size_t hash() const noexcept override
Compute the hash code for this key.
Definition keys.hpp:185
bool eq(const key &other) const noexcept override
Compare this key to another key for equality.
Definition keys.hpp:172
Definition boolean.hpp:26
constant_cell< T > value(const T &value)
Definition constant_cell.hpp:132
auto operator==(const T &a, const U &b)
Create a Cell that compares two cells for equality by ==.
Definition equality.hpp:57
auto operator!=(const T &a, const U &b)
Create a Cell that compares two cells for inequality by !=.
Definition equality.hpp:81