mirror of
https://github.com/BlackMATov/flat.hpp.git
synced 2025-12-15 02:12:23 +07:00
remove Allocator template param
This commit is contained in:
188
README.md
188
README.md
@@ -56,8 +56,7 @@ target_link_libraries(your_project_target flat.hpp)
|
|||||||
```cpp
|
```cpp
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare = std::less<Key>
|
, typename Compare = std::less<Key>
|
||||||
, typename Allocator = std::allocator<Key>
|
, typename Container = std::vector<Key> >
|
||||||
, typename Container = std::vector<Key, Allocator> >
|
|
||||||
class flat_set;
|
class flat_set;
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -71,7 +70,6 @@ class flat_set;
|
|||||||
| `difference_type` | `Container::difference_type` |
|
| `difference_type` | `Container::difference_type` |
|
||||||
| `key_compare` | `Compare` |
|
| `key_compare` | `Compare` |
|
||||||
| `value_compare` | `Compare` |
|
| `value_compare` | `Compare` |
|
||||||
| `allocator_type` | `Allocator` |
|
|
||||||
| `container_type` | `Container` |
|
| `container_type` | `Container` |
|
||||||
| `reference` | `Container::reference` |
|
| `reference` | `Container::reference` |
|
||||||
| `const_reference` | `Container::const_reference` |
|
| `const_reference` | `Container::const_reference` |
|
||||||
@@ -85,43 +83,51 @@ class flat_set;
|
|||||||
### Member functions
|
### Member functions
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
explicit flat_set(
|
flat_set();
|
||||||
const Allocator& a);
|
|
||||||
|
|
||||||
explicit flat_set(
|
explicit flat_set(const Compare& c);
|
||||||
const Compare& c = Compare(),
|
|
||||||
const Allocator& a = Allocator());
|
template < typename Allocator >
|
||||||
|
explicit flat_set(const Allocator& a);
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_set(
|
flat_set(InputIter first, InputIter last);
|
||||||
InputIter first,
|
|
||||||
InputIter last,
|
|
||||||
const Allocator& a);
|
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_set(
|
flat_set(InputIter first, InputIter last, const Compare& c);
|
||||||
InputIter first,
|
|
||||||
InputIter last,
|
|
||||||
const Compare& c = Compare(),
|
|
||||||
const Allocator& a = Allocator());
|
|
||||||
|
|
||||||
flat_set(
|
template < typename InputIter, typename Allocator >
|
||||||
std::initializer_list<value_type> ilist,
|
flat_set(InputIter first, InputIter last, const Allocator& a);
|
||||||
const Allocator& a);
|
|
||||||
|
|
||||||
flat_set(
|
template < typename InputIter, typename Allocator >
|
||||||
std::initializer_list<value_type> ilist,
|
flat_set(InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
const Compare& c = Compare(),
|
|
||||||
const Allocator& a = Allocator());
|
flat_set(std::initializer_list<value_type> ilist);
|
||||||
|
|
||||||
|
flat_set(std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(flat_set&& other, const Allocator& a);
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(const flat_set& other, const Allocator& a);
|
||||||
|
|
||||||
flat_set(flat_set&& other);
|
flat_set(flat_set&& other);
|
||||||
flat_set(const flat_set& other)
|
flat_set(const flat_set& other);
|
||||||
|
|
||||||
flat_set& operator=(flat_set&& other);
|
flat_set& operator=(flat_set&& other);
|
||||||
flat_set& operator=(const flat_set& other);
|
flat_set& operator=(const flat_set& other);
|
||||||
flat_set& operator=(std::initializer_list<value_type> ilist);
|
|
||||||
|
|
||||||
allocator_type get_allocator() const;
|
flat_set& operator=(std::initializer_list<value_type> ilist);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Iterators
|
### Iterators
|
||||||
@@ -211,59 +217,52 @@ value_compare value_comp() const;
|
|||||||
```cpp
|
```cpp
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
void swap(
|
void swap(
|
||||||
flat_set<Key, Compare, Allocator, Container>& l,
|
flat_set<Key, Compare, Container>& l,
|
||||||
flat_set<Key, Compare, Allocator, Container>& r);
|
flat_set<Key, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator==(
|
bool operator==(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r);
|
const flat_set<Key, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator!=(
|
bool operator!=(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r);
|
const flat_set<Key, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator<(
|
bool operator<(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r);
|
const flat_set<Key, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator>(
|
bool operator>(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r);
|
const flat_set<Key, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator<=(
|
bool operator<=(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r);
|
const flat_set<Key, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator>=(
|
bool operator>=(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r);
|
const flat_set<Key, Compare, Container>& r);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Flat Map
|
## Flat Map
|
||||||
@@ -272,8 +271,7 @@ bool operator>=(
|
|||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare = std::less<Key>
|
, typename Compare = std::less<Key>
|
||||||
, typename Allocator = std::allocator<std::pair<Key, Value>>
|
, typename Container = std::vector<std::pair<Key, Value>> >
|
||||||
, typename Container = std::vector<std::pair<Key, Value>, Allocator> >
|
|
||||||
class flat_map;
|
class flat_map;
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -287,7 +285,6 @@ class flat_map;
|
|||||||
| `size_type` | `Container::size_type` |
|
| `size_type` | `Container::size_type` |
|
||||||
| `difference_type` | `Container::difference_type` |
|
| `difference_type` | `Container::difference_type` |
|
||||||
| `key_compare` | `Compare` |
|
| `key_compare` | `Compare` |
|
||||||
| `allocator_type` | `Allocator` |
|
|
||||||
| `container_type` | `Container` |
|
| `container_type` | `Container` |
|
||||||
| `reference` | `Container::reference` |
|
| `reference` | `Container::reference` |
|
||||||
| `const_reference` | `Container::const_reference` |
|
| `const_reference` | `Container::const_reference` |
|
||||||
@@ -307,43 +304,51 @@ class value_compare;
|
|||||||
### Member functions
|
### Member functions
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
explicit flat_map(
|
flat_map();
|
||||||
const Allocator& a);
|
|
||||||
|
|
||||||
explicit flat_map(
|
explicit flat_map(const Compare& c);
|
||||||
const Compare& c = Compare(),
|
|
||||||
const Allocator& a = Allocator());
|
template < typename Allocator >
|
||||||
|
explicit flat_map(const Allocator& a);
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_map(
|
flat_map(InputIter first, InputIter last);
|
||||||
InputIter first,
|
|
||||||
InputIter last,
|
|
||||||
const Allocator& a);
|
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_map(
|
flat_map(InputIter first, InputIter last, const Compare& c);
|
||||||
InputIter first,
|
|
||||||
InputIter last,
|
|
||||||
const Compare& c = Compare(),
|
|
||||||
const Allocator& a = Allocator());
|
|
||||||
|
|
||||||
flat_map(
|
template < typename InputIter, typename Allocator >
|
||||||
std::initializer_list<value_type> ilist,
|
flat_map(InputIter first, InputIter last, const Allocator& a);
|
||||||
const Allocator& a);
|
|
||||||
|
|
||||||
flat_map(
|
template < typename InputIter , typename Allocator >
|
||||||
std::initializer_list<value_type> ilist,
|
flat_map(InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
const Compare& c = Compare(),
|
|
||||||
const Allocator& a = Allocator());
|
flat_map(std::initializer_list<value_type> ilist);
|
||||||
|
|
||||||
|
flat_map(std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(flat_map&& other, const Allocator& a);
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(const flat_map& other, const Allocator& a);
|
||||||
|
|
||||||
flat_map(flat_map&& other);
|
flat_map(flat_map&& other);
|
||||||
flat_map(const flat_map& other);
|
flat_map(const flat_map& other);
|
||||||
|
|
||||||
flat_map& operator=(flat_map&& other);
|
flat_map& operator=(flat_map&& other);
|
||||||
flat_map& operator=(const flat_map& other);
|
flat_map& operator=(const flat_map& other);
|
||||||
flat_map& operator=(std::initializer_list<value_type> ilist);
|
|
||||||
|
|
||||||
allocator_type get_allocator() const;
|
flat_map& operator=(std::initializer_list<value_type> ilist);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Iterators
|
### Iterators
|
||||||
@@ -444,65 +449,58 @@ value_compare value_comp() const;
|
|||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
void swap(
|
void swap(
|
||||||
flat_map<Key, Value, Compare, Allocator, Container>& l,
|
flat_map<Key, Value, Compare, Container>& l,
|
||||||
flat_map<Key, Value, Compare, Allocator, Container>& r);
|
flat_map<Key, Value, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator==(
|
bool operator==(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
const flat_map<Key, Value, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator!=(
|
bool operator!=(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
const flat_map<Key, Value, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator<(
|
bool operator<(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
const flat_map<Key, Value, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator>(
|
bool operator>(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
const flat_map<Key, Value, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator<=(
|
bool operator<=(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
const flat_map<Key, Value, Compare, Container>& r);
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator>=(
|
bool operator>=(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
const flat_map<Key, Value, Compare, Container>& r);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Flat Multiset
|
## Flat Multiset
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ namespace flat_hpp
|
|||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare = std::less<Key>
|
, typename Compare = std::less<Key>
|
||||||
, typename Allocator = std::allocator<std::pair<Key, Value>>
|
, typename Container = std::vector<std::pair<Key, Value>> >
|
||||||
, typename Container = std::vector<std::pair<Key, Value>, Allocator> >
|
|
||||||
class flat_map final {
|
class flat_map final {
|
||||||
class uber_comparer_type : public Compare {
|
class uber_comparer_type : public Compare {
|
||||||
public:
|
public:
|
||||||
@@ -39,6 +38,10 @@ namespace flat_hpp
|
|||||||
bool operator()(typename Container::const_reference l, const Key& r) const {
|
bool operator()(typename Container::const_reference l, const Key& r) const {
|
||||||
return Compare::operator()(l.first, r);
|
return Compare::operator()(l.first, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator()(typename Container::const_reference l, typename Container::const_reference r) const {
|
||||||
|
return Compare::operator()(l.first, r.first);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
using key_type = Key;
|
using key_type = Key;
|
||||||
@@ -49,7 +52,6 @@ namespace flat_hpp
|
|||||||
using difference_type = typename Container::difference_type;
|
using difference_type = typename Container::difference_type;
|
||||||
|
|
||||||
using key_compare = Compare;
|
using key_compare = Compare;
|
||||||
using allocator_type = Allocator;
|
|
||||||
using container_type = Container;
|
using container_type = Container;
|
||||||
|
|
||||||
using reference = typename Container::reference;
|
using reference = typename Container::reference;
|
||||||
@@ -67,78 +69,80 @@ namespace flat_hpp
|
|||||||
bool operator()(const value_type& l, const value_type& r) const {
|
bool operator()(const value_type& l, const value_type& r) const {
|
||||||
return compare_(l.first, r.first);
|
return compare_(l.first, r.first);
|
||||||
}
|
}
|
||||||
private:
|
protected:
|
||||||
friend class flat_map;
|
friend class flat_map;
|
||||||
explicit value_compare(const key_compare& compare)
|
explicit value_compare(key_compare compare)
|
||||||
: compare_(compare) {}
|
: compare_(std::move(compare)) {}
|
||||||
private:
|
private:
|
||||||
key_compare compare_;
|
key_compare compare_;
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(
|
|
||||||
std::is_same<typename allocator_type::value_type, value_type>::value,
|
|
||||||
"Allocator::value_type must be same type as value_type");
|
|
||||||
|
|
||||||
static_assert(
|
|
||||||
std::is_same<typename container_type::value_type, value_type>::value,
|
|
||||||
"Container::value_type must be same type as value_type");
|
|
||||||
|
|
||||||
static_assert(
|
|
||||||
std::is_same<typename container_type::allocator_type, allocator_type>::value,
|
|
||||||
"Container::allocator_type must be same type as allocator_type");
|
|
||||||
public:
|
public:
|
||||||
flat_map() {}
|
flat_map() {}
|
||||||
|
|
||||||
explicit flat_map(
|
explicit flat_map(const Compare& c)
|
||||||
const Allocator& a)
|
: compare_(c) {}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
explicit flat_map(const Allocator& a)
|
||||||
: data_(a) {}
|
: data_(a) {}
|
||||||
|
|
||||||
explicit flat_map(
|
template < typename Allocator >
|
||||||
const Compare& c,
|
flat_map(const Compare& c, const Allocator& a)
|
||||||
const Allocator& a = Allocator())
|
|
||||||
: data_(a)
|
: data_(a)
|
||||||
, compare_(c) {}
|
, compare_(c) {}
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_map(
|
flat_map(InputIter first, InputIter last) {
|
||||||
InputIter first,
|
|
||||||
InputIter last,
|
|
||||||
const Allocator& a)
|
|
||||||
: data_(a) {
|
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_map(
|
flat_map(InputIter first, InputIter last, const Compare& c)
|
||||||
InputIter first,
|
: compare_(c) {
|
||||||
InputIter last,
|
insert(first, last);
|
||||||
const Compare& c = Compare(),
|
}
|
||||||
const Allocator& a = Allocator())
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_map(InputIter first, InputIter last, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename InputIter , typename Allocator >
|
||||||
|
flat_map(InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
: data_(a)
|
: data_(a)
|
||||||
, compare_(c) {
|
, compare_(c) {
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
flat_map(
|
flat_map(std::initializer_list<value_type> ilist) {
|
||||||
std::initializer_list<value_type> ilist,
|
insert(ilist);
|
||||||
const Allocator& a)
|
}
|
||||||
|
|
||||||
|
flat_map(std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
|
: compare_(c) {
|
||||||
|
insert(ilist);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
: data_(a) {
|
: data_(a) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
flat_map(
|
template < typename Allocator >
|
||||||
std::initializer_list<value_type> ilist,
|
flat_map(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
const Compare& c = Compare(),
|
|
||||||
const Allocator& a = Allocator())
|
|
||||||
: data_(a)
|
: data_(a)
|
||||||
, compare_(c) {
|
, compare_(c) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
flat_map(flat_map&& other, const Allocator& a)
|
flat_map(flat_map&& other, const Allocator& a)
|
||||||
: data_(std::move(other.data_), a)
|
: data_(std::move(other.data_), a)
|
||||||
, compare_(std::move(other.compare_)) {}
|
, compare_(std::move(other.compare_)) {}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
flat_map(const flat_map& other, const Allocator& a)
|
flat_map(const flat_map& other, const Allocator& a)
|
||||||
: data_(other.data_, a)
|
: data_(other.data_, a)
|
||||||
, compare_(other.compare_) {}
|
, compare_(other.compare_) {}
|
||||||
@@ -154,10 +158,6 @@ namespace flat_hpp
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
allocator_type get_allocator() const {
|
|
||||||
return data_.get_allocator();
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator begin() noexcept { return data_.begin(); }
|
iterator begin() noexcept { return data_.begin(); }
|
||||||
const_iterator begin() const noexcept { return data_.begin(); }
|
const_iterator begin() const noexcept { return data_.begin(); }
|
||||||
const_iterator cbegin() const noexcept { return data_.cbegin(); }
|
const_iterator cbegin() const noexcept { return data_.cbegin(); }
|
||||||
@@ -230,28 +230,28 @@ namespace flat_hpp
|
|||||||
|
|
||||||
std::pair<iterator, bool> insert(value_type&& value) {
|
std::pair<iterator, bool> insert(value_type&& value) {
|
||||||
const iterator iter = lower_bound(value.first);
|
const iterator iter = lower_bound(value.first);
|
||||||
return iter == end() || compare_(value.first, iter->first)
|
return iter == end() || compare_(value, *iter)
|
||||||
? std::make_pair(data_.insert(iter, std::move(value)), true)
|
? std::make_pair(data_.insert(iter, std::move(value)), true)
|
||||||
: std::make_pair(iter, false);
|
: std::make_pair(iter, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<iterator, bool> insert(const value_type& value) {
|
std::pair<iterator, bool> insert(const value_type& value) {
|
||||||
const iterator iter = lower_bound(value.first);
|
const iterator iter = lower_bound(value.first);
|
||||||
return iter == end() || compare_(value.first, iter->first)
|
return iter == end() || compare_(value, *iter)
|
||||||
? std::make_pair(data_.insert(iter, value), true)
|
? std::make_pair(data_.insert(iter, value), true)
|
||||||
: std::make_pair(iter, false);
|
: std::make_pair(iter, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator insert(const_iterator hint, value_type&& value) {
|
iterator insert(const_iterator hint, value_type&& value) {
|
||||||
return (hint == begin() || compare_((hint - 1)->first, value.first))
|
return (hint == begin() || compare_(*(hint - 1), value))
|
||||||
&& (hint == end() || compare_(value.first, hint->first))
|
&& (hint == end() || compare_(value, *hint))
|
||||||
? data_.insert(hint, std::move(value))
|
? data_.insert(hint, std::move(value))
|
||||||
: insert(std::move(value)).first;
|
: insert(std::move(value)).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator insert(const_iterator hint, const value_type& value) {
|
iterator insert(const_iterator hint, const value_type& value) {
|
||||||
return (hint == begin() || compare_((hint - 1)->first, value.first))
|
return (hint == begin() || compare_(*(hint - 1), value))
|
||||||
&& (hint == end() || compare_(value.first, hint->first))
|
&& (hint == end() || compare_(value, *hint))
|
||||||
? data_.insert(hint, value)
|
? data_.insert(hint, value)
|
||||||
: insert(value).first;
|
: insert(value).first;
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ namespace flat_hpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_type count(const key_type& key) const {
|
size_type count(const key_type& key) const {
|
||||||
const auto iter = find(key);
|
const const_iterator iter = find(key);
|
||||||
return iter != end() ? 1 : 0;
|
return iter != end() ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,11 +363,10 @@ namespace flat_hpp
|
|||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
void swap(
|
void swap(
|
||||||
flat_map<Key, Value, Compare, Allocator, Container>& l,
|
flat_map<Key, Value, Compare, Container>& l,
|
||||||
flat_map<Key, Value, Compare, Allocator, Container>& r)
|
flat_map<Key, Value, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
l.swap(r);
|
l.swap(r);
|
||||||
}
|
}
|
||||||
@@ -375,11 +374,10 @@ namespace flat_hpp
|
|||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator==(
|
bool operator==(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r)
|
const flat_map<Key, Value, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return l.size() == r.size()
|
return l.size() == r.size()
|
||||||
&& std::equal(l.begin(), l.end(), r.begin());
|
&& std::equal(l.begin(), l.end(), r.begin());
|
||||||
@@ -388,11 +386,10 @@ namespace flat_hpp
|
|||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator!=(
|
bool operator!=(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r)
|
const flat_map<Key, Value, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return !(l == r);
|
return !(l == r);
|
||||||
}
|
}
|
||||||
@@ -400,11 +397,10 @@ namespace flat_hpp
|
|||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator<(
|
bool operator<(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r)
|
const flat_map<Key, Value, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return std::lexicographical_compare(l.begin(), l.end(), r.begin(), r.end());
|
return std::lexicographical_compare(l.begin(), l.end(), r.begin(), r.end());
|
||||||
}
|
}
|
||||||
@@ -412,11 +408,10 @@ namespace flat_hpp
|
|||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator>(
|
bool operator>(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r)
|
const flat_map<Key, Value, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return r < l;
|
return r < l;
|
||||||
}
|
}
|
||||||
@@ -424,11 +419,10 @@ namespace flat_hpp
|
|||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator<=(
|
bool operator<=(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r)
|
const flat_map<Key, Value, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return !(r < l);
|
return !(r < l);
|
||||||
}
|
}
|
||||||
@@ -436,11 +430,10 @@ namespace flat_hpp
|
|||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Value
|
, typename Value
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator>=(
|
bool operator>=(
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
const flat_map<Key, Value, Compare, Container>& l,
|
||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r)
|
const flat_map<Key, Value, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return !(l < r);
|
return !(l < r);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ namespace flat_hpp
|
|||||||
{
|
{
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare = std::less<Key>
|
, typename Compare = std::less<Key>
|
||||||
, typename Allocator = std::allocator<Key>
|
, typename Container = std::vector<Key> >
|
||||||
, typename Container = std::vector<Key, Allocator> >
|
|
||||||
class flat_set final {
|
class flat_set final {
|
||||||
public:
|
public:
|
||||||
using key_type = Key;
|
using key_type = Key;
|
||||||
@@ -31,7 +30,6 @@ namespace flat_hpp
|
|||||||
|
|
||||||
using key_compare = Compare;
|
using key_compare = Compare;
|
||||||
using value_compare = Compare;
|
using value_compare = Compare;
|
||||||
using allocator_type = Allocator;
|
|
||||||
using container_type = Container;
|
using container_type = Container;
|
||||||
|
|
||||||
using reference = typename Container::reference;
|
using reference = typename Container::reference;
|
||||||
@@ -43,71 +41,73 @@ namespace flat_hpp
|
|||||||
using const_iterator = typename Container::const_iterator;
|
using const_iterator = typename Container::const_iterator;
|
||||||
using reverse_iterator = typename Container::reverse_iterator;
|
using reverse_iterator = typename Container::reverse_iterator;
|
||||||
using const_reverse_iterator = typename Container::const_reverse_iterator;
|
using const_reverse_iterator = typename Container::const_reverse_iterator;
|
||||||
|
|
||||||
static_assert(
|
|
||||||
std::is_same<typename allocator_type::value_type, value_type>::value,
|
|
||||||
"Allocator::value_type must be same type as value_type");
|
|
||||||
|
|
||||||
static_assert(
|
|
||||||
std::is_same<typename container_type::value_type, value_type>::value,
|
|
||||||
"Container::value_type must be same type as value_type");
|
|
||||||
|
|
||||||
static_assert(
|
|
||||||
std::is_same<typename container_type::allocator_type, allocator_type>::value,
|
|
||||||
"Container::allocator_type must be same type as allocator_type");
|
|
||||||
public:
|
public:
|
||||||
flat_set() {}
|
flat_set() {}
|
||||||
|
|
||||||
explicit flat_set(
|
explicit flat_set(const Compare& c)
|
||||||
const Allocator& a)
|
: compare_(c) {}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
explicit flat_set(const Allocator& a)
|
||||||
: data_(a) {}
|
: data_(a) {}
|
||||||
|
|
||||||
explicit flat_set(
|
template < typename Allocator >
|
||||||
const Compare& c,
|
flat_set(const Compare& c, const Allocator& a)
|
||||||
const Allocator& a = Allocator())
|
|
||||||
: data_(a)
|
: data_(a)
|
||||||
, compare_(c) {}
|
, compare_(c) {}
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_set(
|
flat_set(InputIter first, InputIter last) {
|
||||||
InputIter first,
|
|
||||||
InputIter last,
|
|
||||||
const Allocator& a)
|
|
||||||
: data_(a) {
|
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_set(
|
flat_set(InputIter first, InputIter last, const Compare& c)
|
||||||
InputIter first,
|
: compare_(c) {
|
||||||
InputIter last,
|
insert(first, last);
|
||||||
const Compare& c = Compare(),
|
}
|
||||||
const Allocator& a = Allocator())
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_set(InputIter first, InputIter last, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_set(InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
: data_(a)
|
: data_(a)
|
||||||
, compare_(c) {
|
, compare_(c) {
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
flat_set(
|
flat_set(std::initializer_list<value_type> ilist) {
|
||||||
std::initializer_list<value_type> ilist,
|
insert(ilist);
|
||||||
const Allocator& a)
|
}
|
||||||
|
|
||||||
|
flat_set(std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
|
: compare_(c) {
|
||||||
|
insert(ilist);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
: data_(a) {
|
: data_(a) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
flat_set(
|
template < typename Allocator >
|
||||||
std::initializer_list<value_type> ilist,
|
flat_set(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
const Compare& c = Compare(),
|
|
||||||
const Allocator& a = Allocator())
|
|
||||||
: data_(a)
|
: data_(a)
|
||||||
, compare_(c) {
|
, compare_(c) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
flat_set(flat_set&& other, const Allocator& a)
|
flat_set(flat_set&& other, const Allocator& a)
|
||||||
: data_(std::move(other.data_), a)
|
: data_(std::move(other.data_), a)
|
||||||
, compare_(std::move(other.compare_)) {}
|
, compare_(std::move(other.compare_)) {}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
flat_set(const flat_set& other, const Allocator& a)
|
flat_set(const flat_set& other, const Allocator& a)
|
||||||
: data_(other.data_, a)
|
: data_(other.data_, a)
|
||||||
, compare_(other.compare_) {}
|
, compare_(other.compare_) {}
|
||||||
@@ -123,10 +123,6 @@ namespace flat_hpp
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
allocator_type get_allocator() const {
|
|
||||||
return data_.get_allocator();
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator begin() noexcept { return data_.begin(); }
|
iterator begin() noexcept { return data_.begin(); }
|
||||||
const_iterator begin() const noexcept { return data_.begin(); }
|
const_iterator begin() const noexcept { return data_.begin(); }
|
||||||
const_iterator cbegin() const noexcept { return data_.cbegin(); }
|
const_iterator cbegin() const noexcept { return data_.cbegin(); }
|
||||||
@@ -301,22 +297,20 @@ namespace flat_hpp
|
|||||||
{
|
{
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
void swap(
|
void swap(
|
||||||
flat_set<Key, Compare, Allocator, Container>& l,
|
flat_set<Key, Compare, Container>& l,
|
||||||
flat_set<Key, Compare, Allocator, Container>& r)
|
flat_set<Key, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
l.swap(r);
|
l.swap(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator==(
|
bool operator==(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r)
|
const flat_set<Key, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return l.size() == r.size()
|
return l.size() == r.size()
|
||||||
&& std::equal(l.begin(), l.end(), r.begin());
|
&& std::equal(l.begin(), l.end(), r.begin());
|
||||||
@@ -324,55 +318,50 @@ namespace flat_hpp
|
|||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator!=(
|
bool operator!=(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r)
|
const flat_set<Key, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return !(l == r);
|
return !(l == r);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator<(
|
bool operator<(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r)
|
const flat_set<Key, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return std::lexicographical_compare(l.begin(), l.end(), r.begin(), r.end());
|
return std::lexicographical_compare(l.begin(), l.end(), r.begin(), r.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator>(
|
bool operator>(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r)
|
const flat_set<Key, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return r < l;
|
return r < l;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator<=(
|
bool operator<=(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r)
|
const flat_set<Key, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return !(r < l);
|
return !(r < l);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare
|
, typename Compare
|
||||||
, typename Allocator
|
|
||||||
, typename Container >
|
, typename Container >
|
||||||
bool operator>=(
|
bool operator>=(
|
||||||
const flat_set<Key, Compare, Allocator, Container>& l,
|
const flat_set<Key, Compare, Container>& l,
|
||||||
const flat_set<Key, Compare, Allocator, Container>& r)
|
const flat_set<Key, Compare, Container>& r)
|
||||||
{
|
{
|
||||||
return !(l < r);
|
return !(l < r);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,16 +119,16 @@ TEST_CASE("flat_map") {
|
|||||||
int,
|
int,
|
||||||
unsigned,
|
unsigned,
|
||||||
std::less<int>,
|
std::less<int>,
|
||||||
alloc_t>;
|
std::vector<std::pair<int,unsigned>, alloc_t>>;
|
||||||
|
|
||||||
using map2_t = flat_map<
|
using map2_t = flat_map<
|
||||||
int,
|
int,
|
||||||
unsigned,
|
unsigned,
|
||||||
std::greater<int>,
|
std::greater<int>,
|
||||||
alloc_t>;
|
std::vector<std::pair<int,unsigned>, alloc_t>>;
|
||||||
|
|
||||||
using vec_t = std::vector<
|
using vec_t = std::vector<
|
||||||
std::pair<int,unsigned>>;
|
std::pair<int,unsigned>, alloc_t>;
|
||||||
|
|
||||||
{
|
{
|
||||||
auto s0 = map_t();
|
auto s0 = map_t();
|
||||||
@@ -162,13 +162,6 @@ TEST_CASE("flat_map") {
|
|||||||
REQUIRE(vec_t(s3.begin(), s3.end()) == vec_t({{0,1},{1,2}}));
|
REQUIRE(vec_t(s3.begin(), s3.end()) == vec_t({{0,1},{1,2}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
auto s0 = map_t();
|
|
||||||
auto s1 = map_t(alloc_t(42));
|
|
||||||
REQUIRE(s0.get_allocator().i == 0);
|
|
||||||
REQUIRE(s1.get_allocator().i == 42);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto s0 = map_t{{0,1}, {1,2}};
|
auto s0 = map_t{{0,1}, {1,2}};
|
||||||
auto s1 = s0;
|
auto s1 = s0;
|
||||||
@@ -179,8 +172,6 @@ TEST_CASE("flat_map") {
|
|||||||
REQUIRE(s2 == map_t{{0,1}, {1,2}});
|
REQUIRE(s2 == map_t{{0,1}, {1,2}});
|
||||||
auto s3 = map_t(s2, alloc_t(42));
|
auto s3 = map_t(s2, alloc_t(42));
|
||||||
REQUIRE(s2 == s3);
|
REQUIRE(s2 == s3);
|
||||||
REQUIRE(s2.get_allocator().i == 0);
|
|
||||||
REQUIRE(s3.get_allocator().i == 42);
|
|
||||||
auto s4 = map_t(std::move(s3), alloc_t(21));
|
auto s4 = map_t(std::move(s3), alloc_t(21));
|
||||||
REQUIRE(s3.empty());
|
REQUIRE(s3.empty());
|
||||||
REQUIRE(s4 == map_t{{0,1}, {1,2}});
|
REQUIRE(s4 == map_t{{0,1}, {1,2}});
|
||||||
@@ -251,7 +242,6 @@ TEST_CASE("flat_map") {
|
|||||||
int,
|
int,
|
||||||
unsigned,
|
unsigned,
|
||||||
std::less<int>,
|
std::less<int>,
|
||||||
alloc2_t,
|
|
||||||
std::deque<std::pair<int, unsigned>, alloc2_t>>;
|
std::deque<std::pair<int, unsigned>, alloc2_t>>;
|
||||||
|
|
||||||
map2_t s1;
|
map2_t s1;
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ TEST_CASE("flat_set") {
|
|||||||
}
|
}
|
||||||
SECTION("ctors") {
|
SECTION("ctors") {
|
||||||
using alloc_t = dummy_allocator<int>;
|
using alloc_t = dummy_allocator<int>;
|
||||||
using set_t = flat_set<int, std::less<int>, alloc_t>;
|
using set_t = flat_set<int, std::less<int>, std::vector<int, alloc_t>>;
|
||||||
using set2_t = flat_set<int, std::greater<int>, alloc_t>;
|
using set2_t = flat_set<int, std::greater<int>, std::vector<int, alloc_t>>;
|
||||||
using vec_t = std::vector<int>;
|
using vec_t = std::vector<int>;
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -146,13 +146,6 @@ TEST_CASE("flat_set") {
|
|||||||
REQUIRE(vec_t(s3.begin(), s3.end()) == vec_t({2,1,0}));
|
REQUIRE(vec_t(s3.begin(), s3.end()) == vec_t({2,1,0}));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
auto s0 = set_t();
|
|
||||||
auto s1 = set_t(alloc_t(42));
|
|
||||||
REQUIRE(s0.get_allocator().i == 0);
|
|
||||||
REQUIRE(s1.get_allocator().i == 42);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto s0 = set_t{0,1,2};
|
auto s0 = set_t{0,1,2};
|
||||||
auto s1 = s0;
|
auto s1 = s0;
|
||||||
@@ -163,8 +156,6 @@ TEST_CASE("flat_set") {
|
|||||||
REQUIRE(s2 == set_t{0,1,2});
|
REQUIRE(s2 == set_t{0,1,2});
|
||||||
auto s3 = set_t(s2, alloc_t(42));
|
auto s3 = set_t(s2, alloc_t(42));
|
||||||
REQUIRE(s2 == s3);
|
REQUIRE(s2 == s3);
|
||||||
REQUIRE(s2.get_allocator().i == 0);
|
|
||||||
REQUIRE(s3.get_allocator().i == 42);
|
|
||||||
auto s4 = set_t(std::move(s3), alloc_t(21));
|
auto s4 = set_t(std::move(s3), alloc_t(21));
|
||||||
REQUIRE(s3.empty());
|
REQUIRE(s3.empty());
|
||||||
REQUIRE(s4 == set_t{0,1,2});
|
REQUIRE(s4 == set_t{0,1,2});
|
||||||
@@ -233,7 +224,6 @@ TEST_CASE("flat_set") {
|
|||||||
using set2_t = flat_set<
|
using set2_t = flat_set<
|
||||||
int,
|
int,
|
||||||
std::less<int>,
|
std::less<int>,
|
||||||
alloc2_t,
|
|
||||||
std::deque<int, alloc2_t>>;
|
std::deque<int, alloc2_t>>;
|
||||||
|
|
||||||
set2_t s1;
|
set2_t s1;
|
||||||
|
|||||||
Reference in New Issue
Block a user