Commit 9092da76 authored by Dominik Charousset's avatar Dominik Charousset Committed by Dominik Charousset

Make flat_map members noexcept where possible

parent acc1fa08
...@@ -81,61 +81,55 @@ public: ...@@ -81,61 +81,55 @@ public:
// nop // nop
} }
// -- non-const begin iterators --------------------------------------------- // -- iterator access --------------------------------------------------------
iterator begin() { iterator begin() noexcept {
return xs_.begin(); return xs_.begin();
} }
reverse_iterator rbegin() { const_iterator begin() const noexcept {
return xs_.rbegin();
}
// -- const begin iterators -------------------------------------------------
const_iterator begin() const {
return xs_.begin(); return xs_.begin();
} }
const_iterator cbegin() const { const_iterator cbegin() const noexcept {
return xs_.cbegin(); return xs_.cbegin();
} }
const_reverse_iterator rbegin() const { reverse_iterator rbegin() noexcept {
return xs_.rbegin(); return xs_.rbegin();
} }
// -- non-const end iterators ----------------------------------------------- const_reverse_iterator rbegin() const noexcept {
return xs_.rbegin();
}
iterator end() { iterator end() noexcept {
return xs_.end(); return xs_.end();
} }
reverse_iterator rend() { const_iterator end() const noexcept {
return xs_.rend(); return xs_.end();
} }
// -- const end iterators --------------------------------------------------- const_iterator cend() const noexcept {
const_iterator end() const {
return xs_.end(); return xs_.end();
} }
const_iterator cend() const { reverse_iterator rend() noexcept {
return xs_.end(); return xs_.rend();
} }
const_reverse_iterator rend() const { const_reverse_iterator rend() const noexcept {
return xs_.rend(); return xs_.rend();
} }
// -- capacity -------------------------------------------------------------- // -- size and capacity ------------------------------------------------------
bool empty() const { bool empty() const noexcept {
return xs_.empty(); return xs_.empty();
} }
size_type size() const { size_type size() const noexcept {
return xs_.size(); return xs_.size();
} }
...@@ -147,17 +141,30 @@ public: ...@@ -147,17 +141,30 @@ public:
xs_.shrink_to_fit(); xs_.shrink_to_fit();
} }
// -- access to members ------------------------------------------------------
/// Gives raw access to the underlying container.
vector_type& container() noexcept {
return xs_;
}
/// Gives raw access to the underlying container.
const vector_type& container() const noexcept {
return xs_;
}
// -- modifiers ------------------------------------------------------------- // -- modifiers -------------------------------------------------------------
void clear() { void clear() noexcept {
return xs_.clear(); return xs_.clear();
} }
/// Proves raw access to the underlying container. void swap(unordered_flat_map& other) {
vector_type& container() { xs_.swap(other);
return xs_;
} }
// -- insertion -------------------------------------------------------------
std::pair<iterator, bool> insert(value_type x) { std::pair<iterator, bool> insert(value_type x) {
return insert(end(), std::move(x)); return insert(end(), std::move(x));
} }
...@@ -189,6 +196,8 @@ public: ...@@ -189,6 +196,8 @@ public:
return insert(hint, value_type(std::forward<Ts>(xs)...)); return insert(hint, value_type(std::forward<Ts>(xs)...));
} }
// -- removal ----------------------------------------------------------------
iterator erase(const_iterator i) { iterator erase(const_iterator i) {
return xs_.erase(i); return xs_.erase(i);
} }
...@@ -208,10 +217,6 @@ public: ...@@ -208,10 +217,6 @@ public:
return 1; return 1;
} }
void swap(unordered_flat_map& other) {
xs_.swap(other);
}
// -- lookup ---------------------------------------------------------------- // -- lookup ----------------------------------------------------------------
template <class K> template <class K>
...@@ -262,18 +267,21 @@ private: ...@@ -262,18 +267,21 @@ private:
vector_type xs_; vector_type xs_;
}; };
/// @relates unordered_flat_map
template <class K, class T, class A> template <class K, class T, class A>
bool operator==(const unordered_flat_map<K, T, A>& xs, bool operator==(const unordered_flat_map<K, T, A>& xs,
const unordered_flat_map<K, T, A>& ys) { const unordered_flat_map<K, T, A>& ys) {
return xs.size() == ys.size() && std::equal(xs.begin(), xs.end(), ys.begin()); return xs.size() == ys.size() && std::equal(xs.begin(), xs.end(), ys.begin());
} }
/// @relates unordered_flat_map
template <class K, class T, class A> template <class K, class T, class A>
bool operator!=(const unordered_flat_map<K, T, A>& xs, bool operator!=(const unordered_flat_map<K, T, A>& xs,
const unordered_flat_map<K, T, A>& ys) { const unordered_flat_map<K, T, A>& ys) {
return !(xs == ys); return !(xs == ys);
} }
/// @relates unordered_flat_map
template <class K, class T, class A> template <class K, class T, class A>
bool operator<(const unordered_flat_map<K, T, A>& xs, bool operator<(const unordered_flat_map<K, T, A>& xs,
const unordered_flat_map<K, T, A>& ys) { const unordered_flat_map<K, T, A>& ys) {
...@@ -281,6 +289,7 @@ bool operator<(const unordered_flat_map<K, T, A>& xs, ...@@ -281,6 +289,7 @@ bool operator<(const unordered_flat_map<K, T, A>& xs,
ys.begin(), ys.end()); ys.begin(), ys.end());
} }
/// @relates unordered_flat_map
template <class K, class T, class A> template <class K, class T, class A>
bool operator>=(const unordered_flat_map<K, T, A>& xs, bool operator>=(const unordered_flat_map<K, T, A>& xs,
const unordered_flat_map<K, T, A>& ys) { const unordered_flat_map<K, T, A>& ys) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment