mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:57:46 +00:00
AK+Everywhere: Make StdLibExtras templates less wrapper-y
This commit makes the user-facing StdLibExtras templates and utilities arguably more nice-looking by removing the need to reach into the wrapper structs generated by them to get the value/type needed. The C++ standard library had to invent `_v` and `_t` variants (likely because of backwards compat), but we don't need to cater to any codebase except our own, so might as well have good things for free. :^)
This commit is contained in:
parent
d8d16dea95
commit
a6e4482080
41 changed files with 650 additions and 662 deletions
16
AK/Trie.h
16
AK/Trie.h
|
@ -140,9 +140,9 @@ public:
|
|||
return const_cast<Trie*>(this)->traverse_until_last_accessible_node(it, end);
|
||||
}
|
||||
|
||||
Optional<MetadataType> metadata() const requires(!IsNullPointer<MetadataType>::value) { return m_metadata; }
|
||||
void set_metadata(MetadataType metadata) requires(!IsNullPointer<MetadataType>::value) { m_metadata = move(metadata); }
|
||||
const MetadataType& metadata_value() const requires(!IsNullPointer<MetadataType>::value) { return m_metadata.value(); }
|
||||
Optional<MetadataType> metadata() const requires(!IsNullPointer<MetadataType>) { return m_metadata; }
|
||||
void set_metadata(MetadataType metadata) requires(!IsNullPointer<MetadataType>) { m_metadata = move(metadata); }
|
||||
const MetadataType& metadata_value() const requires(!IsNullPointer<MetadataType>) { return m_metadata.value(); }
|
||||
|
||||
const ValueType& value() const { return m_value; }
|
||||
ValueType& value() { return m_value; }
|
||||
|
@ -165,7 +165,7 @@ public:
|
|||
|
||||
template<typename It, typename ProvideMetadataFunction>
|
||||
BaseType& insert(
|
||||
It& it, const It& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer<MetadataType>::value)
|
||||
It& it, const It& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer<MetadataType>)
|
||||
{
|
||||
Trie* last_root_node = &traverse_until_last_accessible_node(it, end);
|
||||
for (; it != end; ++it)
|
||||
|
@ -175,7 +175,7 @@ public:
|
|||
}
|
||||
|
||||
template<typename It>
|
||||
BaseType& insert(It& it, const It& end) requires(IsNullPointer<MetadataType>::value)
|
||||
BaseType& insert(It& it, const It& end) requires(IsNullPointer<MetadataType>)
|
||||
{
|
||||
Trie* last_root_node = &traverse_until_last_accessible_node(it, end);
|
||||
for (; it != end; ++it)
|
||||
|
@ -185,14 +185,14 @@ public:
|
|||
|
||||
template<typename It, typename ProvideMetadataFunction>
|
||||
BaseType& insert(
|
||||
const It& begin, const It& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer<MetadataType>::value)
|
||||
const It& begin, const It& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer<MetadataType>)
|
||||
{
|
||||
auto it = begin;
|
||||
return insert(it, end, move(metadata), move(provide_missing_metadata));
|
||||
}
|
||||
|
||||
template<typename It>
|
||||
BaseType& insert(const It& begin, const It& end) requires(IsNullPointer<MetadataType>::value)
|
||||
BaseType& insert(const It& begin, const It& end) requires(IsNullPointer<MetadataType>)
|
||||
{
|
||||
auto it = begin;
|
||||
return insert(it, end);
|
||||
|
@ -231,7 +231,7 @@ public:
|
|||
using DetailTrie = Detail::Trie<BaseT, Trie<ValueType, MetadataT, ValueTraits>, ValueType, MetadataT, ValueTraits>;
|
||||
using MetadataType = typename DetailTrie::MetadataType;
|
||||
|
||||
Trie(ValueType value, MetadataType metadata) requires(!IsVoid<MetadataType>::value && !IsNullPointer<MetadataType>::value)
|
||||
Trie(ValueType value, MetadataType metadata) requires(!IsVoid<MetadataType> && !IsNullPointer<MetadataType>)
|
||||
: DetailTrie(move(value), move(metadata))
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue