Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Jun 2, 2024
1 parent f52badc commit 6ec4681
Show file tree
Hide file tree
Showing 11 changed files with 901 additions and 901 deletions.
63 changes: 33 additions & 30 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ template <typename Char> FMT_CONSTEXPR auto length(const Char* s) -> size_t {
}

template <typename Char>
FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, std::size_t n)
-> int {
FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2,
std::size_t n) -> int {
for (; n != 0; ++s1, ++s2, --n) {
if (*s1 < *s2) return -1;
if (*s1 > *s2) return 1;
Expand Down Expand Up @@ -2044,12 +2044,17 @@ FMT_EXPORT using format_args = basic_format_args<format_context>;
# define FMT_ENUM_UNDERLYING_TYPE(type) : type
#endif
namespace align {
enum type FMT_ENUM_UNDERLYING_TYPE(unsigned char){none, left, right, center,
numeric};
enum type FMT_ENUM_UNDERLYING_TYPE(unsigned char) {
none,
left,
right,
center,
numeric
};
}
using align_t = align::type;
namespace sign {
enum type FMT_ENUM_UNDERLYING_TYPE(unsigned char){none, minus, plus, space};
enum type FMT_ENUM_UNDERLYING_TYPE(unsigned char) { none, minus, plus, space };
}
using sign_t = sign::type;

Expand Down Expand Up @@ -2321,10 +2326,9 @@ template <typename Char> struct dynamic_spec_id_handler {

// Parses [integer | "{" [arg_id] "}"].
template <typename Char>
FMT_CONSTEXPR auto parse_dynamic_spec(const Char* begin, const Char* end,
int& value, arg_ref<Char>& ref,
basic_format_parse_context<Char>& ctx)
-> const Char* {
FMT_CONSTEXPR auto parse_dynamic_spec(
const Char* begin, const Char* end, int& value, arg_ref<Char>& ref,
basic_format_parse_context<Char>& ctx) -> const Char* {
FMT_ASSERT(begin != end, "");
if ('0' <= *begin && *begin <= '9') {
int val = parse_nonnegative_int(begin, end, -1);
Expand All @@ -2343,10 +2347,9 @@ FMT_CONSTEXPR auto parse_dynamic_spec(const Char* begin, const Char* end,
}

template <typename Char>
FMT_CONSTEXPR auto parse_precision(const Char* begin, const Char* end,
int& value, arg_ref<Char>& ref,
basic_format_parse_context<Char>& ctx)
-> const Char* {
FMT_CONSTEXPR auto parse_precision(
const Char* begin, const Char* end, int& value, arg_ref<Char>& ref,
basic_format_parse_context<Char>& ctx) -> const Char* {
++begin;
if (begin == end || *begin == '}') {
report_error("invalid precision");
Expand Down Expand Up @@ -2638,8 +2641,8 @@ template <typename T> struct strip_named_arg<T, true> {

template <typename T, typename ParseContext>
FMT_VISIBILITY("hidden") // Suppress an ld warning on macOS (#3769).
FMT_CONSTEXPR auto parse_format_specs(ParseContext& ctx)
-> decltype(ctx.begin()) {
FMT_CONSTEXPR
auto parse_format_specs(ParseContext& ctx) -> decltype(ctx.begin()) {
using char_type = typename ParseContext::char_type;
using context = buffered_context<char_type>;
using mapped_type = conditional_t<
Expand Down Expand Up @@ -2737,8 +2740,8 @@ template <typename Char, typename... Args> class format_string_checker {
on_format_specs(id, begin, begin); // Call parse() on empty specs.
}

FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin, const Char*)
-> const Char* {
FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin,
const Char*) -> const Char* {
context_.advance_to(begin);
// id >= 0 check is a workaround for gcc 10 bug (#2065).
return id >= 0 && id < num_args ? parse_funcs_[id](context_) : begin;
Expand Down Expand Up @@ -2815,8 +2818,8 @@ template <typename T, typename Char, type TYPE> struct native_formatter {
}

template <typename FormatContext>
FMT_CONSTEXPR auto format(const T& val, FormatContext& ctx) const
-> decltype(ctx.out());
FMT_CONSTEXPR auto format(const T& val,
FormatContext& ctx) const -> decltype(ctx.out());
};
} // namespace detail

Expand Down Expand Up @@ -2891,8 +2894,8 @@ inline auto runtime(string_view s) -> runtime_format_string<> { return {{s}}; }
template <typename OutputIt,
FMT_ENABLE_IF(detail::is_output_iterator<remove_cvref_t<OutputIt>,
char>::value)>
auto vformat_to(OutputIt&& out, string_view fmt, format_args args)
-> remove_cvref_t<OutputIt> {
auto vformat_to(OutputIt&& out, string_view fmt,
format_args args) -> remove_cvref_t<OutputIt> {
auto&& buf = detail::get_buffer<char>(out);
detail::vformat_to(buf, fmt, args, {});
return detail::get_iterator(buf, out);
Expand All @@ -2911,8 +2914,8 @@ auto vformat_to(OutputIt&& out, string_view fmt, format_args args)
template <typename OutputIt, typename... T,
FMT_ENABLE_IF(detail::is_output_iterator<remove_cvref_t<OutputIt>,
char>::value)>
FMT_INLINE auto format_to(OutputIt&& out, format_string<T...> fmt, T&&... args)
-> remove_cvref_t<OutputIt> {
FMT_INLINE auto format_to(OutputIt&& out, format_string<T...> fmt,
T&&... args) -> remove_cvref_t<OutputIt> {
return vformat_to(FMT_FWD(out), fmt, fmt::make_format_args(args...));
}

Expand All @@ -2925,8 +2928,8 @@ template <typename OutputIt> struct format_to_n_result {

template <typename OutputIt, typename... T,
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>
auto vformat_to_n(OutputIt out, size_t n, string_view fmt, format_args args)
-> format_to_n_result<OutputIt> {
auto vformat_to_n(OutputIt out, size_t n, string_view fmt,
format_args args) -> format_to_n_result<OutputIt> {
using traits = detail::fixed_buffer_traits;
auto buf = detail::iterator_buffer<OutputIt, char, traits>(out, n);
detail::vformat_to(buf, fmt, args, {});
Expand Down Expand Up @@ -2961,15 +2964,15 @@ struct format_to_result {
};

template <size_t N>
auto vformat_to(char (&out)[N], string_view fmt, format_args args)
-> format_to_result<char*> {
auto vformat_to(char (&out)[N], string_view fmt,
format_args args) -> format_to_result<char*> {
auto result = vformat_to_n(out, N, fmt, args);
return {result.out, result.size > N};
}

template <size_t N, typename... T>
FMT_INLINE auto format_to(char (&out)[N], format_string<T...> fmt, T&&... args)
-> format_to_result<char*> {
FMT_INLINE auto format_to(char (&out)[N], format_string<T...> fmt,
T&&... args) -> format_to_result<char*> {
auto result = fmt::format_to_n(out, N, fmt, static_cast<T&&>(args)...);
return {result.out, result.size > N};
}
Expand All @@ -2993,7 +2996,7 @@ FMT_API void vprintln(FILE* f, string_view fmt, format_args args);
* to `stdout`.
*
* **Example**:
*
*
* fmt::print("The answer is {}.", 42);
*/
template <typename... T>
Expand Down
50 changes: 24 additions & 26 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ template <typename To, typename From,
FMT_ENABLE_IF(!std::is_same<From, To>::value &&
std::numeric_limits<From>::is_signed ==
std::numeric_limits<To>::is_signed)>
FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
-> To {
FMT_CONSTEXPR auto lossless_integral_conversion(const From from,
int& ec) -> To {
ec = 0;
using F = std::numeric_limits<From>;
using T = std::numeric_limits<To>;
Expand Down Expand Up @@ -104,8 +104,8 @@ template <typename To, typename From,
FMT_ENABLE_IF(!std::is_same<From, To>::value &&
std::numeric_limits<From>::is_signed !=
std::numeric_limits<To>::is_signed)>
FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
-> To {
FMT_CONSTEXPR auto lossless_integral_conversion(const From from,
int& ec) -> To {
ec = 0;
using F = std::numeric_limits<From>;
using T = std::numeric_limits<To>;
Expand Down Expand Up @@ -137,8 +137,8 @@ FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)

template <typename To, typename From,
FMT_ENABLE_IF(std::is_same<From, To>::value)>
FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
-> To {
FMT_CONSTEXPR auto lossless_integral_conversion(const From from,
int& ec) -> To {
ec = 0;
return from;
} // function
Expand Down Expand Up @@ -395,8 +395,8 @@ void write_codecvt(codecvt_result<CodeUnit>& out, string_view in_buf,
}

template <typename OutputIt>
auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc)
-> OutputIt {
auto write_encoded_tm_str(OutputIt out, string_view in,
const std::locale& loc) -> OutputIt {
if (detail::use_utf8() && loc != get_classic_locale()) {
// char16_t and char32_t codecvts are broken in MSVC (linkage errors) and
// gcc-4.
Expand Down Expand Up @@ -425,17 +425,17 @@ auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc)

template <typename Char, typename OutputIt,
FMT_ENABLE_IF(!std::is_same<Char, char>::value)>
auto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)
-> OutputIt {
auto write_tm_str(OutputIt out, string_view sv,
const std::locale& loc) -> OutputIt {
codecvt_result<Char> unit;
write_codecvt(unit, sv, loc);
return copy<Char>(unit.buf, unit.end, out);
}

template <typename Char, typename OutputIt,
FMT_ENABLE_IF(std::is_same<Char, char>::value)>
auto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)
-> OutputIt {
auto write_tm_str(OutputIt out, string_view sv,
const std::locale& loc) -> OutputIt {
return write_encoded_tm_str(out, sv, loc);
}

Expand Down Expand Up @@ -503,9 +503,8 @@ auto fmt_duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {
}

template <typename Duration>
auto to_time_t(
std::chrono::time_point<std::chrono::system_clock, Duration> time_point)
-> std::time_t {
auto to_time_t(std::chrono::time_point<std::chrono::system_clock, Duration>
time_point) -> std::time_t {
// Cannot use std::chrono::system_clock::to_time_t since this would first
// require a cast to std::chrono::system_clock::time_point, which could
// overflow.
Expand Down Expand Up @@ -607,9 +606,8 @@ inline auto gmtime(std::time_t time) -> std::tm {
}

template <typename Duration>
inline auto gmtime(
std::chrono::time_point<std::chrono::system_clock, Duration> time_point)
-> std::tm {
inline auto gmtime(std::chrono::time_point<std::chrono::system_clock, Duration>
time_point) -> std::tm {
return gmtime(detail::to_time_t(time_point));
}

Expand Down Expand Up @@ -2230,8 +2228,8 @@ struct formatter<year_month_day, Char> : private formatter<std::tm, Char> {
}

template <typename FormatContext>
auto format(year_month_day val, FormatContext& ctx) const
-> decltype(ctx.out()) {
auto format(year_month_day val,
FormatContext& ctx) const -> decltype(ctx.out()) {
auto time = std::tm();
time.tm_year = static_cast<int>(val.year()) - 1900;
time.tm_mon = static_cast<int>(static_cast<unsigned>(val.month())) - 1;
Expand Down Expand Up @@ -2281,8 +2279,8 @@ struct formatter<std::chrono::duration<Rep, Period>, Char> {
}

template <typename FormatContext>
auto format(std::chrono::duration<Rep, Period> d, FormatContext& ctx) const
-> decltype(ctx.out()) {
auto format(std::chrono::duration<Rep, Period> d,
FormatContext& ctx) const -> decltype(ctx.out()) {
auto specs = specs_;
auto precision = specs.precision;
specs.precision = -1;
Expand Down Expand Up @@ -2353,8 +2351,8 @@ struct formatter<std::chrono::local_time<Duration>, Char>
}

template <typename FormatContext>
auto format(std::chrono::local_time<Duration> val, FormatContext& ctx) const
-> decltype(ctx.out()) {
auto format(std::chrono::local_time<Duration> val,
FormatContext& ctx) const -> decltype(ctx.out()) {
using period = typename Duration::period;
if (period::num != 1 || period::den != 1 ||
std::is_floating_point<typename Duration::rep>::value) {
Expand Down Expand Up @@ -2431,8 +2429,8 @@ template <typename Char> struct formatter<std::tm, Char> {
}

template <typename FormatContext>
auto format(const std::tm& tm, FormatContext& ctx) const
-> decltype(ctx.out()) {
auto format(const std::tm& tm,
FormatContext& ctx) const -> decltype(ctx.out()) {
return do_format<FormatContext, std::chrono::seconds>(tm, ctx, nullptr);
}
};
Expand Down
26 changes: 13 additions & 13 deletions include/fmt/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ enum class color : uint32_t {
white_smoke = 0xF5F5F5, // rgb(245,245,245)
yellow = 0xFFFF00, // rgb(255,255,0)
yellow_green = 0x9ACD32 // rgb(154,205,50)
}; // enum class color
}; // enum class color

enum class terminal_color : uint8_t {
black = 30,
Expand Down Expand Up @@ -257,8 +257,8 @@ class text_style {
return *this;
}

friend FMT_CONSTEXPR auto operator|(text_style lhs, const text_style& rhs)
-> text_style {
friend FMT_CONSTEXPR auto operator|(text_style lhs,
const text_style& rhs) -> text_style {
return lhs |= rhs;
}

Expand Down Expand Up @@ -322,8 +322,8 @@ FMT_CONSTEXPR inline auto bg(detail::color_type background) noexcept
return text_style(false, background);
}

FMT_CONSTEXPR inline auto operator|(emphasis lhs, emphasis rhs) noexcept
-> text_style {
FMT_CONSTEXPR inline auto operator|(emphasis lhs,
emphasis rhs) noexcept -> text_style {
return text_style(lhs) | rhs;
}

Expand Down Expand Up @@ -405,8 +405,8 @@ template <typename Char> struct ansi_color_escape {
out[2] = static_cast<Char>('0' + c % 10);
out[3] = static_cast<Char>(delimiter);
}
static FMT_CONSTEXPR auto has_emphasis(emphasis em, emphasis mask) noexcept
-> bool {
static FMT_CONSTEXPR auto has_emphasis(emphasis em,
emphasis mask) noexcept -> bool {
return static_cast<uint8_t>(em) & static_cast<uint8_t>(mask);
}
};
Expand Down Expand Up @@ -506,8 +506,8 @@ void print(const text_style& ts, format_string<T...> fmt, T&&... args) {
return print(stdout, ts, fmt, std::forward<T>(args)...);
}

inline auto vformat(const text_style& ts, string_view fmt, format_args args)
-> std::string {
inline auto vformat(const text_style& ts, string_view fmt,
format_args args) -> std::string {
auto buf = memory_buffer();
detail::vformat_to(buf, ts, fmt, args);
return fmt::to_string(buf);
Expand All @@ -526,8 +526,8 @@ inline auto vformat(const text_style& ts, string_view fmt, format_args args)
\endrst
*/
template <typename... T>
inline auto format(const text_style& ts, format_string<T...> fmt, T&&... args)
-> std::string {
inline auto format(const text_style& ts, format_string<T...> fmt,
T&&... args) -> std::string {
return fmt::vformat(ts, fmt, fmt::make_format_args(args...));
}

Expand Down Expand Up @@ -565,8 +565,8 @@ inline auto format_to(OutputIt out, const text_style& ts,
template <typename T, typename Char>
struct formatter<detail::styled_arg<T>, Char> : formatter<T, Char> {
template <typename FormatContext>
auto format(const detail::styled_arg<T>& arg, FormatContext& ctx) const
-> decltype(ctx.out()) {
auto format(const detail::styled_arg<T>& arg,
FormatContext& ctx) const -> decltype(ctx.out()) {
const auto& ts = arg.style;
const auto& value = arg.value;
auto out = ctx.out();
Expand Down
12 changes: 6 additions & 6 deletions include/fmt/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ FMT_BEGIN_NAMESPACE
namespace detail {

template <typename T, typename InputIt>
FMT_CONSTEXPR inline auto copy(InputIt begin, InputIt end, counting_iterator it)
-> counting_iterator {
FMT_CONSTEXPR inline auto copy(InputIt begin, InputIt end,
counting_iterator it) -> counting_iterator {
return it + (end - begin);
}

Expand Down Expand Up @@ -492,8 +492,8 @@ FMT_CONSTEXPR OutputIt format_to(OutputIt out, const S&, Args&&... args) {

template <typename OutputIt, typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
auto format_to_n(OutputIt out, size_t n, const S& format_str, Args&&... args)
-> format_to_n_result<OutputIt> {
auto format_to_n(OutputIt out, size_t n, const S& format_str,
Args&&... args) -> format_to_n_result<OutputIt> {
using traits = detail::fixed_buffer_traits;
auto buf = detail::iterator_buffer<OutputIt, char, traits>(out, n);
fmt::format_to(std::back_inserter(buf), format_str,
Expand All @@ -503,8 +503,8 @@ auto format_to_n(OutputIt out, size_t n, const S& format_str, Args&&... args)

template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
FMT_CONSTEXPR20 auto formatted_size(const S& format_str, const Args&... args)
-> size_t {
FMT_CONSTEXPR20 auto formatted_size(const S& format_str,
const Args&... args) -> size_t {
return fmt::format_to(detail::counting_iterator(), format_str, args...)
.count();
}
Expand Down
Loading

0 comments on commit 6ec4681

Please sign in to comment.