diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-07 11:16:08 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-07 11:16:35 +0000 |
commit | 9bb9d8e14827ecc4dba2d43e2d9e76248c120e1d (patch) | |
tree | 9e64c1471c0391410c824f75e2dc1fbfa8585229 /vespalib | |
parent | f2e89d3361cae0e2e74bac89405a175d6ecf5e98 (diff) |
Add noexcept as indicated by -Wnoeexcept
Diffstat (limited to 'vespalib')
22 files changed, 91 insertions, 88 deletions
diff --git a/vespalib/src/tests/delegatelist/delegatelist.cpp b/vespalib/src/tests/delegatelist/delegatelist.cpp index 070864dd85a..4dc7e5c97d7 100644 --- a/vespalib/src/tests/delegatelist/delegatelist.cpp +++ b/vespalib/src/tests/delegatelist/delegatelist.cpp @@ -77,15 +77,15 @@ struct Command int cmd; int cnt; Handler *handler; - Command(DL *dl_, int cmd_, int cnt_, Handler *handler_) + Command(DL *dl_, int cmd_, int cnt_, Handler *handler_) noexcept : dl(dl_), cmd(cmd_), cnt(cnt_), handler(handler_) {} - Command(const Command &rhs) + Command(const Command &rhs) noexcept : dl(rhs.dl), cmd(rhs.cmd), cnt(rhs.cnt), handler(rhs.handler) {} - Command &operator=(const Command &rhs) { + Command &operator=(const Command &rhs) noexcept { memcpy(this, &rhs, sizeof(Command)); return *this; } - bool operator==(const Command &rhs) { + bool operator==(const Command &rhs) noexcept { return memcmp(this, &rhs, sizeof(Command)) == 0; } }; diff --git a/vespalib/src/tests/explore_modern_cpp/explore_modern_cpp_test.cpp b/vespalib/src/tests/explore_modern_cpp/explore_modern_cpp_test.cpp index 1ba368b39a3..29a82138d29 100644 --- a/vespalib/src/tests/explore_modern_cpp/explore_modern_cpp_test.cpp +++ b/vespalib/src/tests/explore_modern_cpp/explore_modern_cpp_test.cpp @@ -5,7 +5,7 @@ TEST("verify how std::function copies lambda closures") { size_t count = 0; size_t value = 0; - auto closure = [count,&value]()mutable{ ++count; value += count; }; + auto closure = [count,&value]() mutable noexcept { ++count; value += count; }; closure(); EXPECT_EQUAL(0u, count); EXPECT_EQUAL(1u, value); // +1 diff --git a/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp b/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp index 434cb8d6a69..eca43ea5cec 100644 --- a/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp +++ b/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp @@ -11,7 +11,7 @@ using namespace vespalib; struct ResultSetter : public AsyncResolver::ResultHandler { SocketAddress &addr; std::atomic<bool> done; - ResultSetter(SocketAddress &addr_out) : addr(addr_out), done(false) {} + ResultSetter(SocketAddress &addr_out) noexcept : addr(addr_out), done(false) {} void handle_result(SocketAddress result) override { addr = result; done = true; @@ -31,7 +31,7 @@ struct MyClock : public AsyncResolver::Clock { struct BlockingHostResolver : public AsyncResolver::HostResolver { CountDownLatch callers; Gate barrier; - BlockingHostResolver(size_t num_callers) + BlockingHostResolver(size_t num_callers) noexcept : callers(num_callers), barrier() {} vespalib::string ip_address(const vespalib::string &) override { callers.countDown(); diff --git a/vespalib/src/tests/priority_queue/priority_queue_test.cpp b/vespalib/src/tests/priority_queue/priority_queue_test.cpp index 3457c2bde6b..af8dd853c6c 100644 --- a/vespalib/src/tests/priority_queue/priority_queue_test.cpp +++ b/vespalib/src/tests/priority_queue/priority_queue_test.cpp @@ -154,11 +154,11 @@ TEST("require that priority queue works with move-only objects") { struct MyItem { int value; int *ref; - MyItem(int v, int &r) : value(v), ref(&r) {} - MyItem(const MyItem &) = delete; - MyItem &operator=(const MyItem &) = delete; - MyItem(MyItem &&rhs) : value(rhs.value), ref(rhs.ref) { rhs.ref = 0; } - MyItem &operator=(MyItem &&rhs) { + MyItem(int v, int &r) noexcept : value(v), ref(&r) {} + MyItem(const MyItem &) noexcept = delete; + MyItem &operator=(const MyItem &) noexcept = delete; + MyItem(MyItem &&rhs) noexcept : value(rhs.value), ref(rhs.ref) { rhs.ref = 0; } + MyItem &operator=(MyItem &&rhs) noexcept { value = rhs.value; ref = rhs.ref; rhs.ref = 0; 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; } }; diff --git a/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp b/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp index a61f9fb5bca..2c1463e506a 100644 --- a/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp +++ b/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp @@ -15,7 +15,7 @@ struct WorkContext { uint64_t _generation; - WorkContext() + WorkContext() noexcept : _generation(0) { } diff --git a/vespalib/src/vespa/vespalib/btree/btree_key_data.h b/vespalib/src/vespa/vespalib/btree/btree_key_data.h index dc44faf00a9..5d4929694d5 100644 --- a/vespalib/src/vespa/vespalib/btree/btree_key_data.h +++ b/vespalib/src/vespa/vespalib/btree/btree_key_data.h @@ -28,12 +28,12 @@ public: KeyT _key; DataT _data; - BTreeKeyData() + BTreeKeyData() noexcept : _key(), _data() {} - BTreeKeyData(const KeyT &key, const DataT &data) + BTreeKeyData(const KeyT &key, const DataT &data) noexcept : _key(key), _data(data) {} @@ -60,9 +60,9 @@ public: KeyT _key; - BTreeKeyData() : _key() {} + BTreeKeyData() noexcept : _key() {} - BTreeKeyData(const KeyT &key, const BTreeNoLeafData &) + BTreeKeyData(const KeyT &key, const BTreeNoLeafData &) noexcept : _key(key) { } diff --git a/vespalib/src/vespa/vespalib/data/databuffer.cpp b/vespalib/src/vespa/vespalib/data/databuffer.cpp index 04c4b1e225b..6b98226e50e 100644 --- a/vespalib/src/vespa/vespalib/data/databuffer.cpp +++ b/vespalib/src/vespa/vespalib/data/databuffer.cpp @@ -11,7 +11,7 @@ size_t padbefore(size_t alignment, const char *buf) { } } -DataBuffer::DataBuffer(size_t len, size_t alignment, const Alloc & initial) +DataBuffer::DataBuffer(size_t len, size_t alignment, const Alloc & initial) noexcept : _alignment(alignment), _externalBuf(nullptr), _bufstart(nullptr), diff --git a/vespalib/src/vespa/vespalib/data/databuffer.h b/vespalib/src/vespa/vespalib/data/databuffer.h index 7c4cd63a7b1..93da2b92379 100644 --- a/vespalib/src/vespa/vespalib/data/databuffer.h +++ b/vespalib/src/vespa/vespalib/data/databuffer.h @@ -44,8 +44,8 @@ public: typedef std::unique_ptr<DataBuffer> UP; DataBuffer(const DataBuffer &) = delete; DataBuffer &operator=(const DataBuffer &) = delete; - DataBuffer(DataBuffer &&) = default; - DataBuffer &operator=(DataBuffer &&) = default; + DataBuffer(DataBuffer &&) noexcept = default; + DataBuffer &operator=(DataBuffer &&) noexcept = default; /** * Construct a databuffer. @@ -53,7 +53,7 @@ public: * @param len the initial size of the buffer. * @param alignment required memory alignment for data start **/ - DataBuffer(size_t len = 1024, size_t alignment = 1, const Alloc & initial = Alloc::alloc(0)); + DataBuffer(size_t len = 1024, size_t alignment = 1, const Alloc & initial = Alloc::alloc(0)) noexcept; /** * Construct a databuffer using externally allocated memory. Note @@ -63,7 +63,7 @@ public: * @param buf pointer to preallocated memory * @param len length of preallocated memory **/ - DataBuffer(void *buf, size_t len) : + DataBuffer(void *buf, size_t len) noexcept : _alignment(1), _externalBuf(static_cast<char *>(buf)), _bufstart(_externalBuf), @@ -73,7 +73,7 @@ public: _buffer(Alloc::alloc(0)) { } - DataBuffer(const void *buf, size_t len) : + DataBuffer(const void *buf, size_t len) noexcept : _alignment(1), _externalBuf(static_cast<char *>(const_cast<void *>(buf))), _bufstart(_externalBuf), diff --git a/vespalib/src/vespa/vespalib/data/slime/slime.h b/vespalib/src/vespa/vespalib/data/slime/slime.h index 6523cd1dac0..3ee608799a6 100644 --- a/vespalib/src/vespa/vespalib/data/slime/slime.h +++ b/vespalib/src/vespa/vespalib/data/slime/slime.h @@ -86,7 +86,7 @@ public: ~Slime(); - Slime(Slime &&rhs) : + Slime(Slime &&rhs) noexcept : _names(std::move(rhs._names)), _stash(std::move(rhs._stash)), _root(std::move(rhs._root)) diff --git a/vespalib/src/vespa/vespalib/datastore/entryref.h b/vespalib/src/vespa/vespalib/datastore/entryref.h index 51a4e0699fc..4a5123ee1b3 100644 --- a/vespalib/src/vespa/vespalib/datastore/entryref.h +++ b/vespalib/src/vespa/vespalib/datastore/entryref.h @@ -13,13 +13,13 @@ class EntryRef { protected: uint32_t _ref; public: - EntryRef() : _ref(0u) { } - explicit EntryRef(uint32_t ref_) : _ref(ref_) { } - uint32_t ref() const { return _ref; } - bool valid() const { return _ref != 0u; } - bool operator==(const EntryRef &rhs) const { return _ref == rhs._ref; } - bool operator!=(const EntryRef &rhs) const { return _ref != rhs._ref; } - bool operator <(const EntryRef &rhs) const { return _ref < rhs._ref; } + EntryRef() noexcept : _ref(0u) { } + explicit EntryRef(uint32_t ref_) noexcept : _ref(ref_) { } + uint32_t ref() const noexcept { return _ref; } + bool valid() const noexcept { return _ref != 0u; } + bool operator==(const EntryRef &rhs) const noexcept { return _ref == rhs._ref; } + bool operator!=(const EntryRef &rhs) const noexcept { return _ref != rhs._ref; } + bool operator <(const EntryRef &rhs) const noexcept { return _ref < rhs._ref; } }; /** @@ -29,9 +29,9 @@ public: template <uint32_t OffsetBits, uint32_t BufferBits = 32u - OffsetBits> class EntryRefT : public EntryRef { public: - EntryRefT() : EntryRef() {} - EntryRefT(size_t offset_, uint32_t bufferId_); - EntryRefT(const EntryRef & ref_) : EntryRef(ref_.ref()) {} + EntryRefT() noexcept : EntryRef() {} + EntryRefT(size_t offset_, uint32_t bufferId_) noexcept; + EntryRefT(const EntryRef & ref_) noexcept : EntryRef(ref_.ref()) {} size_t offset() const { return _ref & (offsetSize() - 1); } uint32_t bufferId() const { return _ref >> OffsetBits; } static size_t offsetSize() { return 1ul << OffsetBits; } @@ -55,10 +55,10 @@ private: typedef EntryRefT<OffsetBits> ParentType; static const uint32_t PadConstant = ((1 << OffsetAlign) - 1); public: - AlignedEntryRefT() : ParentType() {} - AlignedEntryRefT(size_t offset_, uint32_t bufferId_) : + AlignedEntryRefT() noexcept : ParentType() {} + AlignedEntryRefT(size_t offset_, uint32_t bufferId_) noexcept : ParentType(align(offset_) >> OffsetAlign, bufferId_) {} - AlignedEntryRefT(const EntryRef & ref_) : ParentType(ref_) {} + AlignedEntryRefT(const EntryRef & ref_) noexcept : ParentType(ref_) {} size_t offset() const { return ParentType::offset() << OffsetAlign; } static size_t offsetSize() { return ParentType::offsetSize() << OffsetAlign; } static size_t align(size_t val) { return val + pad(val); } diff --git a/vespalib/src/vespa/vespalib/datastore/entryref.hpp b/vespalib/src/vespa/vespalib/datastore/entryref.hpp index 56ebe62dfab..34b8d5355e3 100644 --- a/vespalib/src/vespa/vespalib/datastore/entryref.hpp +++ b/vespalib/src/vespa/vespalib/datastore/entryref.hpp @@ -8,7 +8,7 @@ namespace vespalib::datastore { template <uint32_t OffsetBits, uint32_t BufferBits> -EntryRefT<OffsetBits, BufferBits>::EntryRefT(size_t offset_, uint32_t bufferId_) : +EntryRefT<OffsetBits, BufferBits>::EntryRefT(size_t offset_, uint32_t bufferId_) noexcept : EntryRef((bufferId_ << OffsetBits) + offset_) { ASSERT_ONCE_OR_LOG(offset_ < offsetSize(), "EntryRefT.offset_overflow", 10000); diff --git a/vespalib/src/vespa/vespalib/stllike/string.h b/vespalib/src/vespa/vespalib/stllike/string.h index 7d4ed06c411..f1207c1d9b8 100644 --- a/vespalib/src/vespa/vespalib/stllike/string.h +++ b/vespalib/src/vespa/vespalib/stllike/string.h @@ -180,7 +180,7 @@ public: small_string(const char * s) noexcept : _buf(_stack), _sz(s ? strlen(s) : 0) { init(s); } small_string(const void * s, size_type sz) noexcept : _buf(_stack), _sz(sz) { init(s); } small_string(stringref s) noexcept : _buf(_stack), _sz(s.size()) { init(s.data()); } - small_string(const std::string & s) : _buf(_stack), _sz(s.size()) { init(s.data()); } + small_string(const std::string & s) noexcept : _buf(_stack), _sz(s.size()) { init(s.data()); } small_string(small_string && rhs) noexcept : _sz(rhs.size()), _bufferSize(rhs._bufferSize) { diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp index 29285932f63..1303e7ffdee 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.cpp +++ b/vespalib/src/vespa/vespalib/util/alloc.cpp @@ -510,13 +510,13 @@ Alloc::allocMMap(size_t sz) } Alloc -Alloc::alloc() +Alloc::alloc() noexcept { return Alloc(&AutoAllocator::getDefault()); } Alloc -Alloc::alloc(size_t sz, size_t mmapLimit, size_t alignment) +Alloc::alloc(size_t sz, size_t mmapLimit, size_t alignment) noexcept { return Alloc(&AutoAllocator::getAllocator(mmapLimit, alignment), sz); } diff --git a/vespalib/src/vespa/vespalib/util/alloc.h b/vespalib/src/vespa/vespalib/util/alloc.h index 449cdde5fc7..cf7135736e5 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.h +++ b/vespalib/src/vespa/vespalib/util/alloc.h @@ -81,18 +81,18 @@ public: } return *this; } - Alloc() : _alloc(nullptr, 0), _allocator(nullptr) { } + Alloc() noexcept : _alloc(nullptr, 0), _allocator(nullptr) { } ~Alloc() { if (_alloc.first != nullptr) { _allocator->free(_alloc); _alloc.first = nullptr; } } - void swap(Alloc & rhs) { + void swap(Alloc & rhs) noexcept { std::swap(_alloc, rhs._alloc); std::swap(_allocator, rhs._allocator); } - Alloc create(size_t sz) const { + Alloc create(size_t sz) const noexcept { return (sz == 0) ? Alloc(_allocator) : Alloc(_allocator, sz); } @@ -103,11 +103,11 @@ public: * Optional alignment is assumed to be <= system page size, since mmap * is always used when size is above limit. */ - static Alloc alloc(size_t sz, size_t mmapLimit = MemoryAllocator::HUGEPAGE_SIZE, size_t alignment=0); - static Alloc alloc(); + static Alloc alloc(size_t sz, size_t mmapLimit = MemoryAllocator::HUGEPAGE_SIZE, size_t alignment=0) noexcept; + static Alloc alloc() noexcept; private: - Alloc(const MemoryAllocator * allocator, size_t sz) : _alloc(allocator->alloc(sz)), _allocator(allocator) { } - Alloc(const MemoryAllocator * allocator) : _alloc(nullptr, 0), _allocator(allocator) { } + Alloc(const MemoryAllocator * allocator, size_t sz) noexcept : _alloc(allocator->alloc(sz)), _allocator(allocator) { } + Alloc(const MemoryAllocator * allocator) noexcept : _alloc(nullptr, 0), _allocator(allocator) { } void clear() { _alloc.first = nullptr; _alloc.second = 0; diff --git a/vespalib/src/vespa/vespalib/util/arrayqueue.hpp b/vespalib/src/vespa/vespalib/util/arrayqueue.hpp index 17a8c02dbf5..9af446e7a0f 100644 --- a/vespalib/src/vespa/vespalib/util/arrayqueue.hpp +++ b/vespalib/src/vespa/vespalib/util/arrayqueue.hpp @@ -101,15 +101,16 @@ public: /** * Create an empty queue with an initial capacity of 0. **/ - ArrayQueue() : _data(0), _capacity(0), _used(0), _skew(0) {} + ArrayQueue() noexcept : _data(0), _capacity(0), _used(0), _skew(0) {} /** * Create an empty queue with the given initial capacity. * * @param cap initial capacity **/ - explicit ArrayQueue(uint32_t cap) : _data((T*)malloc(sizeof(T) * cap)), - _capacity(cap), _used(0), _skew(0) {} + explicit ArrayQueue(uint32_t cap) noexcept + : _data((T*)malloc(sizeof(T) * cap)), _capacity(cap), _used(0), _skew(0) + {} /** * Create a queue that is a copy of another queue. Now with funky @@ -119,8 +120,8 @@ public: * @param q the queue that should be copied **/ ArrayQueue(typename std::conditional<is_copyable<T>::value, void_tag, const ArrayQueue &>::type q) = delete; - ArrayQueue(typename std::conditional<is_copyable<T>::value, const ArrayQueue &, void_tag>::type q) : _data((T*)malloc(sizeof(T) * q._capacity)), - _capacity(q._capacity), _used(0), _skew(0) + ArrayQueue(typename std::conditional<is_copyable<T>::value, const ArrayQueue &, void_tag>::type q) + : _data((T*)malloc(sizeof(T) * q._capacity)), _capacity(q._capacity), _used(0), _skew(0) { try { q.copyInto(*this); @@ -136,7 +137,7 @@ public: * * @param q the queue that should be moved **/ - ArrayQueue(ArrayQueue &&q) : _data(0), _capacity(0), _used(0), _skew(0) + ArrayQueue(ArrayQueue &&q) noexcept : _data(0), _capacity(0), _used(0), _skew(0) { swap(q); } @@ -358,7 +359,7 @@ public: * * @param q the queue we want to swap state with **/ - void swap(ArrayQueue<T> &q) { + void swap(ArrayQueue<T> &q) noexcept { std::swap(_data, q._data); std::swap(_capacity, q._capacity); std::swap(_used, q._used); diff --git a/vespalib/src/vespa/vespalib/util/compressionconfig.h b/vespalib/src/vespa/vespalib/util/compressionconfig.h index c0010e8e05c..88563c181a1 100644 --- a/vespalib/src/vespa/vespalib/util/compressionconfig.h +++ b/vespalib/src/vespa/vespalib/util/compressionconfig.h @@ -20,15 +20,15 @@ struct CompressionConfig { ZSTD = 7 }; - CompressionConfig() + CompressionConfig() noexcept : type(NONE), compressionLevel(0), threshold(90), minSize(0) {} - CompressionConfig(Type t) + CompressionConfig(Type t) noexcept : type(t), compressionLevel(9), threshold(90), minSize(0) {} - CompressionConfig(Type t, uint8_t level, uint8_t minRes) + CompressionConfig(Type t, uint8_t level, uint8_t minRes) noexcept : type(t), compressionLevel(level), threshold(minRes), minSize(0) {} - CompressionConfig(Type t, uint8_t lvl, uint8_t minRes, size_t minSz) + CompressionConfig(Type t, uint8_t lvl, uint8_t minRes, size_t minSz) noexcept : type(t), compressionLevel(lvl), threshold(minRes), minSize(minSz) {} bool operator==(const CompressionConfig& o) const { diff --git a/vespalib/src/vespa/vespalib/util/count_down_latch.h b/vespalib/src/vespa/vespalib/util/count_down_latch.h index 66ef1e44cee..420be8f7ab2 100644 --- a/vespalib/src/vespa/vespalib/util/count_down_latch.h +++ b/vespalib/src/vespa/vespalib/util/count_down_latch.h @@ -37,7 +37,7 @@ public: * * @param cnt initial count **/ - CountDownLatch(uint32_t cnt) : _lock(), _cond(), _count(cnt) {} + CountDownLatch(uint32_t cnt) noexcept : _lock(), _cond(), _count(cnt) {} /** * Count down this latch. When the count reaches 0, all threads diff --git a/vespalib/src/vespa/vespalib/util/gate.h b/vespalib/src/vespa/vespalib/util/gate.h index 7d913a7a039..5505a3676df 100644 --- a/vespalib/src/vespa/vespalib/util/gate.h +++ b/vespalib/src/vespa/vespalib/util/gate.h @@ -16,7 +16,7 @@ public: /** * Sets the initial count to 1. **/ - Gate() : CountDownLatch(1) {} + Gate() noexcept : CountDownLatch(1) {} }; } // namespace vespalib diff --git a/vespalib/src/vespa/vespalib/util/memory.h b/vespalib/src/vespa/vespalib/util/memory.h index f1c7c7820f1..2e0d631725a 100644 --- a/vespalib/src/vespa/vespalib/util/memory.h +++ b/vespalib/src/vespa/vespalib/util/memory.h @@ -200,7 +200,7 @@ public: * with default sz=0 you get an empty container * @param sz the number of bytes to allocate **/ - MallocPtr(const size_t sz=0) : _sz(sz), _p(_sz ? malloc(sz) : nullptr) { + MallocPtr(const size_t sz=0) noexcept : _sz(sz), _p(_sz ? malloc(sz) : nullptr) { if (_p == nullptr) { _sz = 0; } @@ -208,7 +208,7 @@ public: /** @brief destructor doing free() if needed */ ~MallocPtr() { cleanup(); } - MallocPtr(MallocPtr && rhs) : + MallocPtr(MallocPtr && rhs) noexcept : _sz(rhs.size()), _p(rhs._p) { rhs._sz = 0; @@ -221,7 +221,7 @@ public: * Does deep copy of contents (using memcpy). * @param rhs container to copy **/ - MallocPtr(const MallocPtr & rhs) + MallocPtr(const MallocPtr & rhs) noexcept : _sz(rhs.size()), _p(_sz ? malloc(_sz) : nullptr) { if (_p == nullptr) { @@ -238,14 +238,14 @@ public: * works like destruct + copy construct. * @param rhs container to copy **/ - MallocPtr & operator = (const MallocPtr & rhs) { + MallocPtr & operator = (const MallocPtr & rhs) noexcept { if (this != &rhs) { MallocPtr tmp(rhs); swap(tmp); } return *this; } - MallocPtr & operator = (MallocPtr && rhs) { + MallocPtr & operator = (MallocPtr && rhs) noexcept { if (this != &rhs) { cleanup(); _sz = rhs._sz; @@ -261,7 +261,7 @@ public: * * does not copy anything, just swaps pointers. **/ - void swap(MallocPtr & rhs) { + void swap(MallocPtr & rhs) noexcept { std::swap(_sz, rhs._sz); std::swap(_p, rhs._p); } @@ -307,7 +307,7 @@ public: } } private: - void cleanup() { + void cleanup() noexcept { if (_p) { free(_p); _p = nullptr; @@ -350,7 +350,7 @@ public: } /** @brief move constructor, takes over ownership */ - CloneablePtr(std::unique_ptr<T> &&rhs) + CloneablePtr(std::unique_ptr<T> &&rhs) noexcept : _p(rhs.release()) { } @@ -373,7 +373,7 @@ public: } /** @brief swap contents */ - void swap(CloneablePtr & rhs) { std::swap(_p, rhs._p); } + void swap(CloneablePtr & rhs) noexcept { std::swap(_p, rhs._p); } /** @brief value access */ const T * get() const { return _p; } diff --git a/vespalib/src/vespa/vespalib/util/sync.h b/vespalib/src/vespa/vespalib/util/sync.h index 8458bc19629..043bb477c89 100644 --- a/vespalib/src/vespa/vespalib/util/sync.h +++ b/vespalib/src/vespa/vespalib/util/sync.h @@ -32,9 +32,10 @@ public: * * Creates a Lock that has mutex instrumentation disabled. **/ - Lock() : _mutex() {} + Lock() noexcept : _mutex() {} + //TODO Remove The below methods are very bad and have a dodgy history. Lock(const Lock &) : Lock() { } - Lock(Lock &&) : Lock() { } + Lock(Lock &&) noexcept : Lock() { } Lock &operator=(const Lock &) { return *this; } Lock &operator=(Lock &&) { return *this; } }; @@ -66,9 +67,10 @@ public: * * Creates a Monitor that has mutex instrumentation disabled. **/ - Monitor() : Lock(), _cond() {} + Monitor() noexcept : Lock(), _cond() {} + //TODO Remove The below methods are very bad and have a dodgy history. Monitor(const Monitor &) : Monitor() { } - Monitor(Monitor &&) : Monitor() { } + Monitor(Monitor &&) noexcept : Monitor() { } Monitor &operator=(const Monitor &) { return *this; } Monitor &operator=(Monitor &&) { return *this; } }; |