summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-03-09 13:48:29 +0100
committerGitHub <noreply@github.com>2022-03-09 13:48:29 +0100
commit84f0ba1167ba7787d2fd6c1a73bae47eda7e02ed (patch)
treee60f4bbdb0711a3390d53206d0727e26abdf3056 /vespalib
parentbd0f51961308733184b8bfb40c49ddbb9dbe7119 (diff)
parentf51b9462ad9e1bcf9431c323307a2c82c8cdb9c8 (diff)
Merge pull request #21609 from vespa-engine/balder/add-noexcept
Add noexcept.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/stllike/hashtable.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/vespalib/src/vespa/vespalib/stllike/hashtable.h b/vespalib/src/vespa/vespalib/stllike/hashtable.h
index af98ad0beb4..4504334a5a8 100644
--- a/vespalib/src/vespa/vespalib/stllike/hashtable.h
+++ b/vespalib/src/vespa/vespalib/stllike/hashtable.h
@@ -102,15 +102,15 @@ class hash_node {
public:
using next_t=hashtable_base::next_t;
enum {npos=-1u, invalid=-2u};
- hash_node()
+ hash_node() noexcept
: _next(invalid)
{}
- hash_node(const V & node, next_t next=npos)
+ hash_node(const V & node, next_t next=npos) noexcept(std::is_nothrow_copy_constructible_v<V>)
: _next(next)
{
new (_node) V(node);
}
- hash_node(V &&node, next_t next=npos)
+ hash_node(V &&node, next_t next=npos) noexcept
: _next(next)
{
new (_node) V(std::move(node));
@@ -132,14 +132,14 @@ public:
}
return *this;
}
- hash_node(const hash_node & rhs)
+ hash_node(const hash_node & rhs) noexcept(std::is_nothrow_copy_constructible_v<V>)
: _next(rhs._next)
{
if (rhs.valid()) {
new (_node) V(rhs.getValue());
}
}
- hash_node &operator=(const hash_node & rhs) {
+ hash_node &operator=(const hash_node & rhs) noexcept (std::is_nothrow_copy_constructible_v<V>) {
destruct();
if (rhs.valid()) {
new (_node) V(rhs.getValue());
@@ -149,25 +149,25 @@ public:
}
return *this;
}
- ~hash_node() {
+ ~hash_node() noexcept {
destruct();
}
- bool operator == (const hash_node & rhs) const {
+ bool operator == (const hash_node & rhs) const noexcept {
return (_next == rhs._next) && (!valid() || (getValue() == rhs.getValue()));
}
- V & getValue() { return *reinterpret_cast<V *>(_node); }
- const V & getValue() const { return *reinterpret_cast<const V *>(_node); }
- next_t getNext() const { return _next; }
- void setNext(next_t next) { _next = next; }
- void invalidate() {
+ V & getValue() noexcept { return *reinterpret_cast<V *>(_node); }
+ const V & getValue() const noexcept { return *reinterpret_cast<const V *>(_node); }
+ next_t getNext() const noexcept { return _next; }
+ void setNext(next_t next) noexcept { _next = next; }
+ void invalidate() noexcept {
destruct();
_next = invalid;
}
- void terminate() { _next = npos; }
- bool valid() const { return _next != invalid; }
- bool hasNext() const { return valid() && (_next != npos); }
+ void terminate() noexcept { _next = npos; }
+ bool valid() const noexcept { return _next != invalid; }
+ bool hasNext() const noexcept { return valid() && (_next != npos); }
private:
- void destruct() {
+ void destruct() noexcept {
if constexpr (!can_skip_destruction<V>::value) {
if (valid()) {
getValue().~V();