Introduce ctl::to_string()

This commit is contained in:
Justine Tunney 2024-07-01 05:40:38 -07:00
parent acbabedf27
commit e627bfa359
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
11 changed files with 432 additions and 40 deletions

View file

@ -338,11 +338,27 @@ class string
return *this;
}
string operator+(const char c) const noexcept
{
char s[2] = { c };
return strcat(*this, s);
}
string operator+(const string& s) const noexcept
{
return strcat(*this, s);
}
string operator+(const ctl::string_view s) const noexcept
{
return strcat(*this, s);
}
string operator+(const char* s) const noexcept
{
return strcat(*this, s);
}
int compare(const ctl::string_view s) const noexcept
{
return strcmp(*this, s);
@ -409,6 +425,33 @@ static_assert(sizeof(string) == __::string_size);
static_assert(sizeof(__::small_string) == __::string_size);
static_assert(sizeof(__::big_string) == __::string_size);
ctl::string
to_string(int);
ctl::string
to_string(long);
ctl::string
to_string(long long);
ctl::string
to_string(unsigned);
ctl::string
to_string(unsigned long);
ctl::string
to_string(unsigned long long);
ctl::string
to_string(float);
ctl::string
to_string(double);
ctl::string
to_string(long double);
} // namespace ctl
#pragma GCC diagnostic push