mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Introduce ctl::to_string()
This commit is contained in:
parent
acbabedf27
commit
e627bfa359
11 changed files with 432 additions and 40 deletions
43
ctl/string.h
43
ctl/string.h
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue