Add compile_map tests

This commit is contained in:
Christian Mazakas
2022-10-12 13:37:12 -07:00
parent 05b3025c0e
commit 3f9bd00f01
4 changed files with 173 additions and 3 deletions

View File

@@ -35,9 +35,12 @@ namespace boost {
using init_type = std::pair<Key, T>;
using moved_type = std::pair<Key&&, T&&>;
using value_type = std::pair<Key const, T>;
static Key const& extract(init_type const& kv) { return kv.first; }
static Key const& extract(value_type const& kv) { return kv.first; }
static Key const& extract(moved_type const& kv) { return kv.first; }
template <class K, class V>
static K const& extract(std::pair<K, V> const& kv)
{
return kv.first;
}
static moved_type move(value_type& x)
{
@@ -57,6 +60,7 @@ namespace boost {
using mapped_type = T;
using value_type = typename map_types::value_type;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
using hasher = Hash;
using key_equal = KeyEqual;
using allocator_type = Allocator;
@@ -79,6 +83,11 @@ namespace boost {
{
}
unordered_flat_map(size_type n, hasher const& h, allocator_type const& a)
: unordered_flat_map(n, h, key_equal(), a)
{
}
explicit unordered_flat_map(allocator_type const& a)
: unordered_flat_map(0, a)
{
@@ -93,6 +102,20 @@ namespace boost {
this->insert(first, last);
}
template <class Iterator>
unordered_flat_map(
Iterator first, Iterator last, size_type n, allocator_type const& a)
: unordered_flat_map(first, last, n, hasher(), key_equal(), a)
{
}
template <class Iterator>
unordered_flat_map(Iterator first, Iterator last, size_type n,
hasher const& h, allocator_type const& a)
: unordered_flat_map(first, last, n, h, key_equal(), a)
{
}
unordered_flat_map(unordered_flat_map const& other) : table_(other.table_)
{
}
@@ -124,6 +147,18 @@ namespace boost {
{
}
unordered_flat_map(std::initializer_list<value_type> init, size_type n,
allocator_type const& a)
: unordered_flat_map(init, n, hasher(), key_equal(), a)
{
}
unordered_flat_map(std::initializer_list<value_type> init, size_type n,
hasher const& h, allocator_type const& a)
: unordered_flat_map(init, n, h, key_equal(), a)
{
}
~unordered_flat_map() = default;
unordered_flat_map& operator=(unordered_flat_map const& other)
@@ -165,6 +200,8 @@ namespace boost {
size_type size() const noexcept { return table_.size(); }
size_type max_size() const noexcept { return table_.max_size(); }
/// Modifiers
///
@@ -302,6 +339,22 @@ namespace boost {
table_.swap(rhs.table_);
}
template <class H2, class P2>
void merge(
unordered_flat_map<key_type, mapped_type, H2, P2, allocator_type>&
source)
{
(void)source;
}
template <class H2, class P2>
void merge(
unordered_flat_map<key_type, mapped_type, H2, P2, allocator_type>&&
source)
{
(void)source;
}
/// Lookup
///