Skip to content

Commit

Permalink
cow_string,static_char_buffer: Cleanup
Browse files Browse the repository at this point in the history
(cherry picked from commit 4e0b1cf)
Signed-off-by: LIU Hao <[email protected]>
  • Loading branch information
lhmouse committed Apr 22, 2024
1 parent aedd15a commit e140272
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions rocket/cow_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class basic_shallow_string
m_ptr(*ps), m_len((ROCKET_ASSERT(*(*ps + N - 1) == charT()), N - 1))
{ }

template<size_t N>
constexpr basic_shallow_string(charT (*ps)[N]) = delete;

public:
constexpr
const charT*
Expand Down Expand Up @@ -156,17 +159,34 @@ class basic_cow_string
m_ref(s_zstr), m_sth(alloc)
{ }

constexpr basic_cow_string(shallow_type sh, const allocator_type& alloc = allocator_type()) noexcept
constexpr basic_cow_string(shallow_type sh) noexcept(is_nothrow_constructible<allocator_type>::value)
:
m_ref(sh), m_sth()
{ }

constexpr basic_cow_string(shallow_type sh, const allocator_type& alloc) noexcept
:
m_ref(sh), m_sth(alloc)
{ }

template<size_t N>
constexpr basic_cow_string(const value_type (*ps)[N], const allocator_type& alloc = allocator_type()) noexcept
constexpr basic_cow_string(const value_type (*ps)[N]) noexcept(is_nothrow_constructible<allocator_type>::value)
:
m_ref(ps), m_sth()
{ }

template<size_t N>
constexpr basic_cow_string(const value_type (*ps)[N], const allocator_type& alloc) noexcept
:
m_ref(ps), m_sth(alloc)
{ }

template<size_t N>
constexpr basic_cow_string(value_type (*ps)[N]) = delete;

template<size_t N>
constexpr basic_cow_string(value_type (*ps)[N], const allocator_type& alloc) = delete;

basic_cow_string(const basic_cow_string& other) noexcept
:
m_ref(other.m_ref),
Expand Down Expand Up @@ -238,6 +258,10 @@ class basic_cow_string
return *this;
}

template<size_t N>
basic_cow_string&
operator=(value_type (*ps)[N]) & = delete;

basic_cow_string&
operator=(const basic_cow_string& other) & noexcept
{
Expand Down

0 comments on commit e140272

Please sign in to comment.