79# include <initializer_list>
80# include <type_traits>
88template<
typename T>
class DynList;
123# define Special_Ctors(Set_Type, Type) \
124 template <template <typename> class List> \
125 Set_Type(const List<Type> & l) : Set_Type() \
127 l.for_each([this] (const Type & item) { (void)this->append(item); }); \
130 template <class It> \
131 requires (not std::is_arithmetic_v<It> \
132 and requires (It it) { *it; ++it; it != it; }) \
133 Set_Type(It b, It e) : Set_Type() \
135 for (It it = b; it != e; ++it) \
136 (void)this->append(*it); \
139 Set_Type(std::initializer_list<Type> l) : Set_Type() \
141 for (const auto & item : l) \
142 (void)this->append(item); \
151# define Generic_Items(Type) \
152 template <template <typename> class Container = DynList> \
153 Container<Type> items() const \
155 return this->template maps<Type, Container> ([] (const Type & key) \
163# define Generate_Proxy_Operator(Class_Name) \
164 const Data & operator [] (const Key & key) const \
169 Data & operator [] (const Key & key) \
183template<
typename Type>
inline
186 std::ostringstream os;
204template<
typename Key,
typename Data,
class Cmp = std::equal_to<Key>>
236 const std::pair<Key, Data> &p2)
const
237 noexcept(std::is_nothrow_invocable_r_v<bool,
const Cmp &,
238 const Key &,
const Key &>)
240 return cmp(p1.first, p2.first);
246 noexcept(std::is_nothrow_invocable_r_v<bool,
const Cmp &,
247 const Key &,
const Key &>)
249 return cmp(p.first,
k);
254 const std::pair<Key, Data> &p)
const
255 noexcept(std::is_nothrow_invocable_r_v<bool,
const Cmp &,
256 const Key &,
const Key &>)
258 return cmp(
k, p.first);
266template<
typename Key,
typename Data>
269 using PairType = std::pair<Key, Data>;
270 return reinterpret_cast<PairType *
>(
271 reinterpret_cast<char *
>(ptr) - offsetof(PairType, first));
275template<
typename Key,
typename Data>
278 using PairType = std::pair<Key, Data>;
279 return reinterpret_cast<const PairType *
>(
280 reinterpret_cast<const char *
>(ptr) - offsetof(PairType, first));
287template<
typename Key,
typename Data>
290 using PairType = std::pair<Key, Data>;
291 return reinterpret_cast<PairType *
>(
292 reinterpret_cast<char *
>(ptr) - offsetof(PairType, second));
296template<
typename Key,
typename Data>
299 using PairType = std::pair<Key, Data>;
300 return reinterpret_cast<const PairType *
>(
301 reinterpret_cast<const char *
>(ptr) - offsetof(PairType, second));
Exception handling system with formatted messages for Aleph-w.
Functional programming utilities for Aleph-w containers.
Main namespace for Aleph-w library functions.
std::pair< Key, Data > * key_to_pair(Key *ptr)
Converts a pointer to Key to a pointer to the containing pair.
std::pair< Key, Data > * data_to_pair(Data *ptr)
Converts a pointer to Data to a pointer to the containing pair.
std::string to_str(const double d)
Convert double to a std::string with maximum round-trip precision.
Default comparator for pair types in hash maps.
bool operator()(const Key &k, const std::pair< Key, Data > &p) const noexcept(std::is_nothrow_invocable_r_v< bool, const Cmp &, const Key &, const Key & >)
Heterogeneous: Key vs Pair; it throws what cmp throws.
bool operator()(const std::pair< Key, Data > &p, const Key &k) const noexcept(std::is_nothrow_invocable_r_v< bool, const Cmp &, const Key &, const Key & >)
Heterogeneous: Pair vs Key; it throws what cmp throws.
Dft_Pair_Cmp() noexcept(std::is_nothrow_default_constructible_v< Cmp >)
Builds the comparator of the keys by default.
bool operator()(const std::pair< Key, Data > &p1, const std::pair< Key, Data > &p2) const noexcept(std::is_nothrow_invocable_r_v< bool, const Cmp &, const Key &, const Key & >)
Pair vs Pair comparison; it throws what cmp throws.
Dft_Pair_Cmp(Cmp __cmp) noexcept(std::is_nothrow_constructible_v< Cmp, Cmp & >)
Wraps the comparator __cmp of the keys.