From 72f8c0d5928edf28bb0cb1e6e701f0fe2d9b13ae Mon Sep 17 00:00:00 2001 From: rexy712 Date: Sat, 18 Apr 2020 09:47:10 -0700 Subject: [PATCH] Fix static_string not allowing move construction --- include/rexy/string_base.hpp | 4 ++-- include/rexy/string_base.tpp | 10 ++++++++++ src/string_base.cpp | 5 ----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/rexy/string_base.hpp b/include/rexy/string_base.hpp index 4a6d11f..6c1c6d0 100644 --- a/include/rexy/string_base.hpp +++ b/include/rexy/string_base.hpp @@ -149,8 +149,8 @@ namespace rexy{ ~static_string(void) = default; static_string& operator=(const char* c); - static_string& operator=(const static_string& s); - static_string& operator=(static_string&&) = delete; + constexpr static_string& operator=(const static_string& s); + constexpr static_string& operator=(static_string&&); }; diff --git a/include/rexy/string_base.tpp b/include/rexy/string_base.tpp index 92845f9..fce2717 100644 --- a/include/rexy/string_base.tpp +++ b/include/rexy/string_base.tpp @@ -240,6 +240,16 @@ namespace rexy{ string_base(s.m_data, s.m_length, s.m_length){} constexpr static_string::static_string(static_string&& s): string_base(s.m_data, s.m_length, s.m_length){} + constexpr static_string& static_string::operator=(const static_string& s){ + m_data = s.m_data; + m_length = s.m_length; + return *this; + } + constexpr static_string& static_string::operator=(static_string&& s){ + m_data = s.m_data; + m_length = s.m_length; + return *this; + } namespace detail{ template diff --git a/src/string_base.cpp b/src/string_base.cpp index 2925d0f..a4a6445 100644 --- a/src/string_base.cpp +++ b/src/string_base.cpp @@ -40,10 +40,5 @@ namespace rexy{ m_length = strlen(c); return *this; } - static_string& static_string::operator=(const static_string& s){ - m_data = s.m_data; - m_length = s.m_length; - return *this; - } }