summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-10-28 20:01:27 +0000
committerMaxime Coste <frrrwww@gmail.com>2014-10-28 20:01:27 +0000
commitd3091cb553283ad854ae61b5faf362a006bf3f6d (patch)
treeeb1c8bd10c8d18acf05a8bc414a69571f1aa02be /src
parent00aede6e577f024b50524c7c9cce87ae2a4f325b (diff)
Add noexcept spec to move constructor and move assign
Diffstat (limited to 'src')
-rw-r--r--src/interned_string.cc2
-rw-r--r--src/interned_string.hh8
-rw-r--r--src/optional.hh1
-rw-r--r--src/safe_ptr.hh4
4 files changed, 9 insertions, 6 deletions
diff --git a/src/interned_string.cc b/src/interned_string.cc
index b949233f..1a7b5627 100644
--- a/src/interned_string.cc
+++ b/src/interned_string.cc
@@ -40,7 +40,7 @@ void StringRegistry::acquire(size_t slot)
++m_storage[slot].second;
}
-void StringRegistry::release(size_t slot)
+void StringRegistry::release(size_t slot) noexcept
{
if (--m_storage[slot].second == 0)
{
diff --git a/src/interned_string.hh b/src/interned_string.hh
index 23eeab92..43df5fb4 100644
--- a/src/interned_string.hh
+++ b/src/interned_string.hh
@@ -18,7 +18,7 @@ private:
InternedString acquire(StringView str);
void acquire(size_t slot);
- void release(size_t slot);
+ void release(size_t slot) noexcept;
std::unordered_map<StringView, size_t> m_slot_map;
std::vector<size_t> m_free_slots;
@@ -62,8 +62,10 @@ public:
return *this;
}
- InternedString& operator=(InternedString&& str)
+ InternedString& operator=(InternedString&& str) noexcept
{
+ release_ifn();
+
static_cast<StringView&>(*this) = str;
m_slot = str.m_slot;
str.m_slot = -1;
@@ -110,7 +112,7 @@ private:
*this = StringRegistry::instance().acquire(str);
}
- void release_ifn()
+ void release_ifn() noexcept
{
if (m_slot != -1)
StringRegistry::instance().release(m_slot);
diff --git a/src/optional.hh b/src/optional.hh
index 68277b1a..3f919043 100644
--- a/src/optional.hh
+++ b/src/optional.hh
@@ -20,6 +20,7 @@ public:
}
Optional(Optional&& other)
+ noexcept(noexcept(new ((void*)0) T(std::move(other.m_value))))
: m_valid(other.m_valid)
{
if (m_valid)
diff --git a/src/safe_ptr.hh b/src/safe_ptr.hh
index 6a53a02e..ac3af21d 100644
--- a/src/safe_ptr.hh
+++ b/src/safe_ptr.hh
@@ -29,7 +29,7 @@ public:
#endif
}
safe_ptr(const safe_ptr& other) : safe_ptr(other.m_ptr) {}
- safe_ptr(safe_ptr&& other) : m_ptr(other.m_ptr)
+ safe_ptr(safe_ptr&& other) noexcept : m_ptr(other.m_ptr)
{
other.m_ptr = nullptr;
#ifdef KAK_DEBUG
@@ -60,7 +60,7 @@ public:
return *this;
}
- safe_ptr& operator=(safe_ptr&& other)
+ safe_ptr& operator=(safe_ptr&& other) noexcept
{
#ifdef KAK_DEBUG
if (m_ptr)