Add noexcept spec to move constructor and move assign
This commit is contained in:
parent
00aede6e57
commit
d3091cb553
|
@ -40,7 +40,7 @@ void StringRegistry::acquire(size_t slot)
|
||||||
++m_storage[slot].second;
|
++m_storage[slot].second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringRegistry::release(size_t slot)
|
void StringRegistry::release(size_t slot) noexcept
|
||||||
{
|
{
|
||||||
if (--m_storage[slot].second == 0)
|
if (--m_storage[slot].second == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ private:
|
||||||
|
|
||||||
InternedString acquire(StringView str);
|
InternedString acquire(StringView str);
|
||||||
void acquire(size_t slot);
|
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::unordered_map<StringView, size_t> m_slot_map;
|
||||||
std::vector<size_t> m_free_slots;
|
std::vector<size_t> m_free_slots;
|
||||||
|
@ -62,8 +62,10 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
InternedString& operator=(InternedString&& str)
|
InternedString& operator=(InternedString&& str) noexcept
|
||||||
{
|
{
|
||||||
|
release_ifn();
|
||||||
|
|
||||||
static_cast<StringView&>(*this) = str;
|
static_cast<StringView&>(*this) = str;
|
||||||
m_slot = str.m_slot;
|
m_slot = str.m_slot;
|
||||||
str.m_slot = -1;
|
str.m_slot = -1;
|
||||||
|
@ -110,7 +112,7 @@ private:
|
||||||
*this = StringRegistry::instance().acquire(str);
|
*this = StringRegistry::instance().acquire(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_ifn()
|
void release_ifn() noexcept
|
||||||
{
|
{
|
||||||
if (m_slot != -1)
|
if (m_slot != -1)
|
||||||
StringRegistry::instance().release(m_slot);
|
StringRegistry::instance().release(m_slot);
|
||||||
|
|
|
@ -20,6 +20,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional(Optional&& other)
|
Optional(Optional&& other)
|
||||||
|
noexcept(noexcept(new ((void*)0) T(std::move(other.m_value))))
|
||||||
: m_valid(other.m_valid)
|
: m_valid(other.m_valid)
|
||||||
{
|
{
|
||||||
if (m_valid)
|
if (m_valid)
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
safe_ptr(const safe_ptr& other) : safe_ptr(other.m_ptr) {}
|
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;
|
other.m_ptr = nullptr;
|
||||||
#ifdef KAK_DEBUG
|
#ifdef KAK_DEBUG
|
||||||
|
@ -60,7 +60,7 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_ptr& operator=(safe_ptr&& other)
|
safe_ptr& operator=(safe_ptr&& other) noexcept
|
||||||
{
|
{
|
||||||
#ifdef KAK_DEBUG
|
#ifdef KAK_DEBUG
|
||||||
if (m_ptr)
|
if (m_ptr)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user