Skip to content

Commit

Permalink
Mark ctl::to_string() noexcept
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Jul 1, 2024
1 parent e627bfa commit c1f8d06
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
18 changes: 9 additions & 9 deletions ctl/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,31 +426,31 @@ static_assert(sizeof(__::small_string) == __::string_size);
static_assert(sizeof(__::big_string) == __::string_size);

ctl::string
to_string(int);
to_string(int) noexcept;

ctl::string
to_string(long);
to_string(long) noexcept;

ctl::string
to_string(long long);
to_string(long long) noexcept;

ctl::string
to_string(unsigned);
to_string(unsigned) noexcept;

ctl::string
to_string(unsigned long);
to_string(unsigned long) noexcept;

ctl::string
to_string(unsigned long long);
to_string(unsigned long long) noexcept;

ctl::string
to_string(float);
to_string(float) noexcept;

ctl::string
to_string(double);
to_string(double) noexcept;

ctl::string
to_string(long double);
to_string(long double) noexcept;

} // namespace ctl

Expand Down
18 changes: 9 additions & 9 deletions ctl/to_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,49 @@ namespace ctl {
extern const double_conversion::DoubleToStringConverter kDoubleToPrintfG;

string
to_string(int value)
to_string(int value) noexcept
{
char buf[12];
return { buf, FormatInt32(buf, value) - buf };
}

string
to_string(unsigned value)
to_string(unsigned value) noexcept
{
char buf[12];
return { buf, FormatUint32(buf, value) - buf };
}

string
to_string(long value)
to_string(long value) noexcept
{
char buf[21];
return { buf, FormatInt64(buf, value) - buf };
}

string
to_string(unsigned long value)
to_string(unsigned long value) noexcept
{
char buf[21];
return { buf, FormatUint64(buf, value) - buf };
}

string
to_string(long long value)
to_string(long long value) noexcept
{
char buf[21];
return { buf, FormatInt64(buf, value) - buf };
}

string
to_string(unsigned long long value)
to_string(unsigned long long value) noexcept
{
char buf[21];
return { buf, FormatUint64(buf, value) - buf };
}

string
to_string(float value)
to_string(float value) noexcept
{
char buf[128];
double_conversion::StringBuilder b(buf, sizeof(buf));
Expand All @@ -79,7 +79,7 @@ to_string(float value)
}

string
to_string(double value)
to_string(double value) noexcept
{
char buf[128];
double_conversion::StringBuilder b(buf, sizeof(buf));
Expand All @@ -89,7 +89,7 @@ to_string(double value)
}

string
to_string(long double value)
to_string(long double value) noexcept
{
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
return to_string((double)value);
Expand Down
1 change: 0 additions & 1 deletion test/ctl/to_string_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// PERFORMANCE OF THIS SOFTWARE.

#include "ctl/string.h"
#include "libc/intrin/kprintf.h"
#include "libc/limits.h"
#include "libc/math.h"
#include "libc/mem/leaks.h"
Expand Down

0 comments on commit c1f8d06

Please sign in to comment.