Add noexcept spec to move constructor and move assign

This commit is contained in:
Maxime Coste 2014-10-28 20:01:27 +00:00
parent 00aede6e57
commit d3091cb553
4 changed files with 9 additions and 6 deletions

View File

@ -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)
{

View File

@ -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);

View File

@ -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)

View File

@ -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)