Mark ctl::to_string() noexcept

This commit is contained in:
Justine Tunney 2024-07-01 05:54:22 -07:00
parent e627bfa359
commit c1f8d0678c
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
3 changed files with 18 additions and 19 deletions

View file

@ -426,31 +426,31 @@ static_assert(sizeof(__::small_string) == __::string_size);
static_assert(sizeof(__::big_string) == __::string_size); static_assert(sizeof(__::big_string) == __::string_size);
ctl::string ctl::string
to_string(int); to_string(int) noexcept;
ctl::string ctl::string
to_string(long); to_string(long) noexcept;
ctl::string ctl::string
to_string(long long); to_string(long long) noexcept;
ctl::string ctl::string
to_string(unsigned); to_string(unsigned) noexcept;
ctl::string ctl::string
to_string(unsigned long); to_string(unsigned long) noexcept;
ctl::string ctl::string
to_string(unsigned long long); to_string(unsigned long long) noexcept;
ctl::string ctl::string
to_string(float); to_string(float) noexcept;
ctl::string ctl::string
to_string(double); to_string(double) noexcept;
ctl::string ctl::string
to_string(long double); to_string(long double) noexcept;
} // namespace ctl } // namespace ctl

View file

@ -27,49 +27,49 @@ namespace ctl {
extern const double_conversion::DoubleToStringConverter kDoubleToPrintfG; extern const double_conversion::DoubleToStringConverter kDoubleToPrintfG;
string string
to_string(int value) to_string(int value) noexcept
{ {
char buf[12]; char buf[12];
return { buf, FormatInt32(buf, value) - buf }; return { buf, FormatInt32(buf, value) - buf };
} }
string string
to_string(unsigned value) to_string(unsigned value) noexcept
{ {
char buf[12]; char buf[12];
return { buf, FormatUint32(buf, value) - buf }; return { buf, FormatUint32(buf, value) - buf };
} }
string string
to_string(long value) to_string(long value) noexcept
{ {
char buf[21]; char buf[21];
return { buf, FormatInt64(buf, value) - buf }; return { buf, FormatInt64(buf, value) - buf };
} }
string string
to_string(unsigned long value) to_string(unsigned long value) noexcept
{ {
char buf[21]; char buf[21];
return { buf, FormatUint64(buf, value) - buf }; return { buf, FormatUint64(buf, value) - buf };
} }
string string
to_string(long long value) to_string(long long value) noexcept
{ {
char buf[21]; char buf[21];
return { buf, FormatInt64(buf, value) - buf }; return { buf, FormatInt64(buf, value) - buf };
} }
string string
to_string(unsigned long long value) to_string(unsigned long long value) noexcept
{ {
char buf[21]; char buf[21];
return { buf, FormatUint64(buf, value) - buf }; return { buf, FormatUint64(buf, value) - buf };
} }
string string
to_string(float value) to_string(float value) noexcept
{ {
char buf[128]; char buf[128];
double_conversion::StringBuilder b(buf, sizeof(buf)); double_conversion::StringBuilder b(buf, sizeof(buf));
@ -79,7 +79,7 @@ to_string(float value)
} }
string string
to_string(double value) to_string(double value) noexcept
{ {
char buf[128]; char buf[128];
double_conversion::StringBuilder b(buf, sizeof(buf)); double_conversion::StringBuilder b(buf, sizeof(buf));
@ -89,7 +89,7 @@ to_string(double value)
} }
string string
to_string(long double value) to_string(long double value) noexcept
{ {
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
return to_string((double)value); return to_string((double)value);

View file

@ -17,7 +17,6 @@
// PERFORMANCE OF THIS SOFTWARE. // PERFORMANCE OF THIS SOFTWARE.
#include "ctl/string.h" #include "ctl/string.h"
#include "libc/intrin/kprintf.h"
#include "libc/limits.h" #include "libc/limits.h"
#include "libc/math.h" #include "libc/math.h"
#include "libc/mem/leaks.h" #include "libc/mem/leaks.h"