|
@@ -17,17 +17,17 @@ public:
|
|
|
static inline constexpr size_type npos = (-1U);
|
|
|
|
|
|
public:
|
|
|
- explicit string(size_type capacity = 8)
|
|
|
+ explicit constexpr string(size_type capacity = 8)
|
|
|
: inner_vector_type(capacity)
|
|
|
{
|
|
|
this->push_back(0x00);
|
|
|
}
|
|
|
- string(const char* str, size_type n = npos)
|
|
|
+ constexpr string(const char* str, size_type n = npos)
|
|
|
: string()
|
|
|
{
|
|
|
this->append(str, n);
|
|
|
}
|
|
|
- string& append(const char* str, size_type n = npos)
|
|
|
+ constexpr string& append(const char* str, size_type n = npos)
|
|
|
{
|
|
|
this->pop_back();
|
|
|
|
|
@@ -39,51 +39,51 @@ public:
|
|
|
this->push_back(0x00);
|
|
|
return *this;
|
|
|
}
|
|
|
- string& append(const string& str)
|
|
|
+ constexpr string& append(const string& str)
|
|
|
{
|
|
|
return this->append(str.data());
|
|
|
}
|
|
|
- string& append(string&& str)
|
|
|
+ constexpr string& append(string&& str)
|
|
|
{
|
|
|
return this->append(str.data());
|
|
|
}
|
|
|
- string& operator+=(const char c)
|
|
|
+ constexpr string& operator+=(const char c)
|
|
|
{
|
|
|
this->pop_back();
|
|
|
this->push_back(c);
|
|
|
this->push_back(0x00);
|
|
|
return *this;
|
|
|
}
|
|
|
- string& operator+=(const char* str)
|
|
|
+ constexpr string& operator+=(const char* str)
|
|
|
{
|
|
|
return this->append(str);
|
|
|
}
|
|
|
- string& operator+=(const string& str)
|
|
|
+ constexpr string& operator+=(const string& str)
|
|
|
{
|
|
|
return this->append(str);
|
|
|
}
|
|
|
- string& operator+=(string&& str)
|
|
|
+ constexpr string& operator+=(string&& str)
|
|
|
{
|
|
|
return this->append(move(str));
|
|
|
}
|
|
|
- bool operator==(const string& rhs) const
|
|
|
+ constexpr bool operator==(const string& rhs) const
|
|
|
{
|
|
|
return strcmp(c_str(), rhs.c_str()) == 0;
|
|
|
}
|
|
|
- string substr(size_type pos, size_type n = npos)
|
|
|
+ constexpr string substr(size_type pos, size_type n = npos)
|
|
|
{
|
|
|
return string(this->m_arr + pos, n);
|
|
|
}
|
|
|
- const char* c_str(void) const noexcept
|
|
|
+ constexpr const char* c_str(void) const noexcept
|
|
|
{
|
|
|
return this->data();
|
|
|
}
|
|
|
- void clear(void)
|
|
|
+ constexpr void clear(void)
|
|
|
{
|
|
|
inner_vector_type::clear();
|
|
|
this->push_back(0x00);
|
|
|
}
|
|
|
- char pop(void)
|
|
|
+ constexpr char pop(void)
|
|
|
{
|
|
|
this->pop_back();
|
|
|
auto iter = inner_vector_type::back();
|
|
@@ -91,21 +91,21 @@ public:
|
|
|
*iter = 0x00;
|
|
|
return c;
|
|
|
}
|
|
|
- typename inner_vector_type::iterator_type back(void)
|
|
|
+ constexpr typename inner_vector_type::iterator_type back(void)
|
|
|
{
|
|
|
// TODO: assert
|
|
|
if (this->empty())
|
|
|
return typename inner_vector_type::iterator_type((void*)0xffffffff);
|
|
|
return --inner_vector_type::back();
|
|
|
}
|
|
|
- typename inner_vector_type::const_iterator_type back(void) const
|
|
|
+ constexpr typename inner_vector_type::const_iterator_type back(void) const
|
|
|
{
|
|
|
// TODO: assert
|
|
|
if (this->empty())
|
|
|
return typename inner_vector_type::iterator_type((void*)0xffffffff);
|
|
|
return --inner_vector_type::back();
|
|
|
}
|
|
|
- typename inner_vector_type::const_iterator_type cback(void) const
|
|
|
+ constexpr typename inner_vector_type::const_iterator_type cback(void) const
|
|
|
{
|
|
|
// TODO: assert
|
|
|
if (this->empty())
|