diff options
Diffstat (limited to 'vespalib/src/tests/stllike')
-rw-r--r-- | vespalib/src/tests/stllike/hash_test.cpp | 12 | ||||
-rw-r--r-- | vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp | 16 |
2 files changed, 14 insertions, 14 deletions
diff --git a/vespalib/src/tests/stllike/hash_test.cpp b/vespalib/src/tests/stllike/hash_test.cpp index e86a9ad020a..d6f5c2ba65d 100644 --- a/vespalib/src/tests/stllike/hash_test.cpp +++ b/vespalib/src/tests/stllike/hash_test.cpp @@ -15,14 +15,14 @@ namespace { struct Foo { int i; - Foo() : i(0) {} - Foo(int i_) : i(i_) {} + Foo() noexcept : i(0) {} + Foo(int i_) noexcept : i(i_) {} - bool operator==(const Foo& f) const + bool operator==(const Foo& f) const noexcept { return (i == f.i); } struct hash { - size_t operator() (const Foo& f) const { + size_t operator() (const Foo& f) const noexcept { return (f.i % 16); } }; @@ -332,10 +332,10 @@ TEST("test hash map with simple key and value type") class S { public: - explicit S(uint64_t l=0) : _a(l&0xfffffffful), _b(l>>32) { } + explicit S(uint64_t l=0) noexcept : _a(l&0xfffffffful), _b(l>>32) { } uint32_t hash() const { return _a; } uint32_t a() const { return _a; } - friend bool operator == (const S & a, const S & b) { return a._a == b._a && a._b == b._b; } + friend bool operator == (const S & a, const S & b) noexcept { return a._a == b._a && a._b == b._b; } private: uint32_t _a, _b; }; diff --git a/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp b/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp index 72a0c93c719..faee7680426 100644 --- a/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp +++ b/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp @@ -71,13 +71,13 @@ class Gid { public: struct hash { - size_t operator () (const Gid & g) const { return g.getGid()[0]; } + size_t operator () (const Gid & g) const noexcept { return g.getGid()[0]; } }; - Gid(unsigned int v=0) : _gid() { _gid[0] = _gid[1] = _gid[2] = v; } + Gid(unsigned int v=0) noexcept : _gid() { _gid[0] = _gid[1] = _gid[2] = v; } const unsigned int * getGid() const { return _gid; } - int cmp(const Gid & b) const { return memcmp(_gid, b._gid, sizeof(_gid)); } - bool operator < (const Gid & b) const { return cmp(b) < 0; } - bool operator == (const Gid & b) const { return cmp(b) == 0; } + int cmp(const Gid & b) const noexcept { return memcmp(_gid, b._gid, sizeof(_gid)); } + bool operator < (const Gid & b) const noexcept { return cmp(b) < 0; } + bool operator == (const Gid & b) const noexcept { return cmp(b) == 0; } private: unsigned int _gid[3]; }; @@ -85,15 +85,15 @@ private: class Slot { public: - Slot(unsigned int v=0) : _gid(v) { } + Slot(unsigned int v=0) noexcept : _gid(v) { } const Gid & getGid() const { return _gid; } - int cmp(const Slot & b) const { return _gid.cmp(b.getGid()); } + int cmp(const Slot & b) const noexcept { return _gid.cmp(b.getGid()); } private: Gid _gid; }; struct IndirectCmp : public std::binary_function<Slot*, Slot*, bool> { - bool operator()(const Slot* s1, const Slot* s2) { + bool operator() (const Slot* s1, const Slot* s2) noexcept { return s1->cmp(*s2) < 0; } }; |