From 2808395481a36dbf1dcbd5b49e1488823f3c6f67 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 7 Apr 2019 10:05:49 -0700 Subject: [PATCH] basic_buffer -> buffer This reduces symbol sizes and gets rid of shadowing warnings. --- include/fmt/core.h | 31 ++++++++++++++----------------- include/fmt/format-inl.h | 12 ++++++------ include/fmt/format.h | 34 +++++++++++++++++----------------- include/fmt/locale.h | 4 ++-- include/fmt/ostream.h | 8 ++++---- include/fmt/prepare.h | 6 +++--- include/fmt/printf.h | 26 +++++++++++++------------- include/format | 8 ++++---- src/format.cc | 16 ++++++++-------- test/core-test.cc | 28 ++++++++++++++-------------- test/custom-formatter-test.cc | 5 +++-- test/format-test.cc | 13 +++++++------ test/ostream-test.cc | 6 +++--- test/ranges-test.cc | 4 ++-- 14 files changed, 100 insertions(+), 101 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 5ba58e1a..8733b427 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -241,10 +241,10 @@ FMT_CONSTEXPR typename std::make_unsigned::type to_unsigned(Int value) { } /** A contiguous memory buffer with an optional growing ability. */ -template class basic_buffer { +template class buffer { private: - basic_buffer(const basic_buffer&) = delete; - void operator=(const basic_buffer&) = delete; + buffer(const buffer&) = delete; + void operator=(const buffer&) = delete; T* ptr_; std::size_t size_; @@ -252,12 +252,12 @@ template class basic_buffer { protected: // Don't initialize ptr_ since it is not accessed to save a few cycles. - basic_buffer(std::size_t sz) FMT_NOEXCEPT : size_(sz), capacity_(sz) {} + buffer(std::size_t sz) FMT_NOEXCEPT : size_(sz), capacity_(sz) {} - basic_buffer(T* p = FMT_NULL, std::size_t sz = 0, - std::size_t cap = 0) FMT_NOEXCEPT : ptr_(p), - size_(sz), - capacity_(cap) {} + buffer(T* p = FMT_NULL, std::size_t sz = 0, std::size_t cap = 0) FMT_NOEXCEPT + : ptr_(p), + size_(sz), + capacity_(cap) {} /** Sets the buffer data and capacity. */ void set(T* buf_data, std::size_t buf_capacity) FMT_NOEXCEPT { @@ -272,7 +272,7 @@ template class basic_buffer { typedef T value_type; typedef const T& const_reference; - virtual ~basic_buffer() {} + virtual ~buffer() {} T* begin() FMT_NOEXCEPT { return ptr_; } T* end() FMT_NOEXCEPT { return ptr_ + size_; } @@ -317,12 +317,9 @@ template class basic_buffer { const T& operator[](std::size_t index) const { return ptr_[index]; } }; -typedef basic_buffer buffer; -typedef basic_buffer wbuffer; - // A container-backed buffer. template -class container_buffer : public basic_buffer { +class container_buffer : public buffer { private: Container& container_; @@ -334,7 +331,7 @@ class container_buffer : public basic_buffer { public: explicit container_buffer(Container& c) - : basic_buffer(c.size()), container_(c) {} + : buffer(c.size()), container_(c) {} }; // Extracts a reference to the container from back_insert_iterator. @@ -1141,7 +1138,7 @@ template class basic_format_context { template struct buffer_context { typedef basic_format_context< - std::back_insert_iterator>, Char> + std::back_insert_iterator>, Char> type; }; typedef buffer_context::type format_context; @@ -1381,7 +1378,7 @@ std::basic_string vformat( template typename buffer_context::type::iterator vformat_to( - internal::basic_buffer& buf, basic_string_view format_str, + internal::buffer& buf, basic_string_view format_str, basic_format_args::type> args); } // namespace internal @@ -1415,7 +1412,7 @@ template struct is_contiguous> : std::true_type {}; template -struct is_contiguous> : std::true_type {}; +struct is_contiguous> : std::true_type {}; /** Formats a string and writes the output to ``out``. */ template diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 3f13d816..15b8c6dd 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -85,7 +85,7 @@ inline int fmt_snprintf(char* buffer, size_t size, const char* format, ...) { # define FMT_SWPRINTF swprintf #endif // defined(_WIN32) && defined(__MINGW32__) && !defined(__NO_ISOCEXT) -typedef void (*FormatFunc)(internal::buffer&, int, string_view); +typedef void (*FormatFunc)(internal::buffer&, int, string_view); // Portable thread-safe version of strerror. // Sets buffer to point to a string describing the error code. @@ -154,7 +154,7 @@ int safe_strerror(int error_code, char*& buffer, return dispatcher(error_code, buffer, buffer_size).run(); } -void format_error_code(internal::buffer& out, int error_code, +void format_error_code(internal::buffer& out, int error_code, string_view message) FMT_NOEXCEPT { // Report error code making sure that the output fits into // inline_buffer_size to avoid dynamic memory allocation and potential @@ -661,7 +661,7 @@ struct shortest_handler { template ::type> -FMT_FUNC bool grisu2_format(Double value, buffer& buf, int precision, +FMT_FUNC bool grisu2_format(Double value, buffer& buf, int precision, bool fixed, int& exp) { FMT_ASSERT(value >= 0, "value is negative"); if (value <= 0) { // <= instead of == to silence a warning. @@ -713,7 +713,7 @@ FMT_FUNC bool grisu2_format(Double value, buffer& buf, int precision, } template -void sprintf_format(Double value, internal::buffer& buf, +void sprintf_format(Double value, internal::buffer& buf, core_format_specs spec) { // Buffer capacity must be non-zero, otherwise MSVC's vsnprintf_s will fail. FMT_ASSERT(buf.capacity() != 0, "empty buffer"); @@ -849,7 +849,7 @@ FMT_FUNC void windows_error::init(int err_code, string_view format_str, base = std::runtime_error(to_string(buffer)); } -FMT_FUNC void internal::format_windows_error(internal::buffer& out, +FMT_FUNC void internal::format_windows_error(internal::buffer& out, int error_code, string_view message) FMT_NOEXCEPT { FMT_TRY { @@ -883,7 +883,7 @@ FMT_FUNC void internal::format_windows_error(internal::buffer& out, #endif // FMT_USE_WINDOWS_H -FMT_FUNC void format_system_error(internal::buffer& out, int error_code, +FMT_FUNC void format_system_error(internal::buffer& out, int error_code, string_view message) FMT_NOEXCEPT { FMT_TRY { memory_buffer buf; diff --git a/include/fmt/format.h b/include/fmt/format.h index b022292a..1582625a 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -352,8 +352,8 @@ class back_insert_range back_insert_range(typename base::iterator it) : base(it) {} }; -typedef basic_writer> writer; -typedef basic_writer> wwriter; +typedef basic_writer>> writer; +typedef basic_writer>> wwriter; /** A formatting error such as invalid format string. */ class format_error : public std::runtime_error { @@ -383,7 +383,7 @@ template inline T* make_checked(T* p, std::size_t) { return p; } template template -void basic_buffer::append(const U* begin, const U* end) { +void buffer::append(const U* begin, const U* end) { std::size_t new_size = size_ + internal::to_unsigned(end - begin); reserve(new_size); std::uninitialized_copy(begin, end, @@ -454,8 +454,7 @@ enum { inline_buffer_size = 500 }; */ template > -class basic_memory_buffer : private Allocator, - public internal::basic_buffer { +class basic_memory_buffer : private Allocator, public internal::buffer { private: T store_[SIZE]; @@ -1087,7 +1086,8 @@ class utf16_to_utf8 { FMT_API int convert(wstring_view s); }; -FMT_API void format_windows_error(fmt::internal::buffer& out, int error_code, +FMT_API void format_windows_error(fmt::internal::buffer& out, + int error_code, fmt::string_view message) FMT_NOEXCEPT; #endif @@ -1149,10 +1149,10 @@ namespace internal { // Formats value using Grisu2 algorithm: // https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf template -FMT_API bool grisu2_format(Double value, buffer& buf, int precision, bool fixed, - int& exp); +FMT_API bool grisu2_format(Double value, buffer& buf, int precision, + bool fixed, int& exp); template -inline bool grisu2_format(Double, buffer&, int, bool, int&) { +inline bool grisu2_format(Double, buffer&, int, bool, int&) { return false; } @@ -1242,7 +1242,7 @@ It grisu2_prettify(const char* digits, int size, int exp, It it, } template -void sprintf_format(Double, internal::buffer&, core_format_specs); +void sprintf_format(Double, internal::buffer&, core_format_specs); template FMT_CONSTEXPR void handle_int_type_spec(char spec, Handler&& handler) { @@ -2405,7 +2405,7 @@ class system_error : public std::runtime_error { may look like "Unknown error -1" and is platform-dependent. \endrst */ -FMT_API void format_system_error(internal::buffer& out, int error_code, +FMT_API void format_system_error(internal::buffer& out, int error_code, fmt::string_view message) FMT_NOEXCEPT; /** @@ -2654,7 +2654,7 @@ template class basic_writer { struct double_writer { char sign; - internal::buffer& buffer; + internal::buffer& buffer; size_t size() const { return buffer.size() + (sign ? 1 : 0); } size_t width() const { return size(); } @@ -2667,14 +2667,14 @@ template class basic_writer { class grisu_writer { private: - internal::buffer& digits_; + internal::buffer& digits_; size_t size_; char sign_; int exp_; internal::gen_digits_params params_; public: - grisu_writer(char sign, internal::buffer& digits, int exp, + grisu_writer(char sign, internal::buffer& digits, int exp, const internal::gen_digits_params& params) : digits_(digits), sign_(sign), exp_(exp), params_(params) { int num_digits = static_cast(digits.size()); @@ -3392,9 +3392,9 @@ std::basic_string to_string(const basic_memory_buffer& buf) { template typename buffer_context::type::iterator internal::vformat_to( - internal::basic_buffer& buf, basic_string_view format_str, + internal::buffer& buf, basic_string_view format_str, basic_format_args::type> args) { - typedef back_insert_range> range; + typedef back_insert_range> range; return vformat_to>(buf, to_string_view(format_str), args); } @@ -3402,7 +3402,7 @@ typename buffer_context::type::iterator internal::vformat_to( template ::value)> inline typename buffer_context::type::iterator vformat_to( - internal::basic_buffer& buf, const S& format_str, + internal::buffer& buf, const S& format_str, basic_format_args::type> args) { return internal::vformat_to(buf, to_string_view(format_str), args); } diff --git a/include/fmt/locale.h b/include/fmt/locale.h index 4a33b666..aeb35217 100644 --- a/include/fmt/locale.h +++ b/include/fmt/locale.h @@ -16,10 +16,10 @@ FMT_BEGIN_NAMESPACE namespace internal { template typename buffer_context::type::iterator vformat_to( - const std::locale& loc, basic_buffer& buf, + const std::locale& loc, buffer& buf, basic_string_view format_str, basic_format_args::type> args) { - typedef back_insert_range> range; + typedef back_insert_range> range; return vformat_to>(buf, to_string_view(format_str), args, internal::locale_ref(loc)); } diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 5f70fed6..8af60c0d 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -19,10 +19,10 @@ template class formatbuf : public std::basic_streambuf { typedef typename std::basic_streambuf::int_type int_type; typedef typename std::basic_streambuf::traits_type traits_type; - basic_buffer& buffer_; + buffer& buffer_; public: - formatbuf(basic_buffer& buffer) : buffer_(buffer) {} + formatbuf(buffer& buffer) : buffer_(buffer) {} protected: // The put-area is actually always empty. This makes the implementation @@ -71,7 +71,7 @@ template class is_streamable { // Write the content of buf to os. template -void write(std::basic_ostream& os, basic_buffer& buf) { +void write(std::basic_ostream& os, buffer& buf) { const Char* data = buf.data(); typedef std::make_unsigned::type UnsignedStreamSize; UnsignedStreamSize size = buf.size(); @@ -86,7 +86,7 @@ void write(std::basic_ostream& os, basic_buffer& buf) { } template -void format_value(basic_buffer& buffer, const T& value) { +void format_value(buffer& buffer, const T& value) { internal::formatbuf format_buf(buffer); std::basic_ostream output(&format_buf); output.exceptions(std::ios_base::failbit | std::ios_base::badbit); diff --git a/include/fmt/prepare.h b/include/fmt/prepare.h index 2e063e1e..bfa7d816 100644 --- a/include/fmt/prepare.h +++ b/include/fmt/prepare.h @@ -216,7 +216,7 @@ class prepared_format { std::basic_string format(const Args&... args) const { basic_memory_buffer buffer; - typedef back_insert_range> range; + typedef back_insert_range> range; this->vformat_to(range(buffer), make_args_checked(format_, args...)); return to_string(buffer); } @@ -225,7 +225,7 @@ class prepared_format { inline std::back_insert_iterator format_to( std::back_insert_iterator out, const Args&... args) const { internal::container_buffer buffer(internal::get_container(out)); - typedef back_insert_range> range; + typedef back_insert_range> range; this->vformat_to(range(buffer), make_args_checked(format_, args...)); return out; } @@ -241,7 +241,7 @@ class prepared_format { template inline typename buffer_context::type::iterator format_to( basic_memory_buffer& buf, const Args&... args) const { - typedef back_insert_range> range; + typedef back_insert_range> range; return this->vformat_to(range(buf), make_args_checked(format_, args...)); } diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 50a3de48..32d07f6c 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -180,7 +180,7 @@ class printf_width_handler : public function { }; template -void printf(basic_buffer& buf, basic_string_view format, +void printf(buffer& buf, basic_string_view format, basic_format_args args) { Context(std::back_inserter(buf), format, args).format(); } @@ -198,8 +198,8 @@ using internal::printf; // For printing into memory_buffer. template class printf_arg_formatter; template >>> + typename ArgFormatter = + printf_arg_formatter>>> class basic_printf_context; /** @@ -578,8 +578,8 @@ template struct basic_printf_context_t { type; }; -typedef basic_printf_context_t::type printf_context; -typedef basic_printf_context_t::type wprintf_context; +typedef basic_printf_context_t>::type printf_context; +typedef basic_printf_context_t>::type wprintf_context; typedef basic_format_args printf_args; typedef basic_format_args wprintf_args; @@ -612,7 +612,7 @@ template inline std::basic_string vsprintf( const S& format, basic_format_args< - typename basic_printf_context_t>::type> + typename basic_printf_context_t>::type> args) { basic_memory_buffer buffer; printf(buffer, to_string_view(format), args); @@ -633,7 +633,7 @@ template sprintf(const S& format, const Args&... args) { internal::check_format_string(format); - typedef internal::basic_buffer buffer; + typedef internal::buffer buffer; typedef typename basic_printf_context_t::type context; format_arg_store as{args...}; return vsprintf(to_string_view(format), basic_format_args(as)); @@ -643,7 +643,7 @@ template inline int vfprintf( std::FILE* f, const S& format, basic_format_args< - typename basic_printf_context_t>::type> + typename basic_printf_context_t>::type> args) { basic_memory_buffer buffer; printf(buffer, to_string_view(format), args); @@ -666,7 +666,7 @@ template ::value)> inline int fprintf(std::FILE* f, const S& format, const Args&... args) { internal::check_format_string(format); - typedef internal::basic_buffer buffer; + typedef internal::buffer buffer; typedef typename basic_printf_context_t::type context; format_arg_store as{args...}; return vfprintf(f, to_string_view(format), basic_format_args(as)); @@ -676,7 +676,7 @@ template inline int vprintf( const S& format, basic_format_args< - typename basic_printf_context_t>::type> + typename basic_printf_context_t>::type> args) { return vfprintf(stdout, to_string_view(format), args); } @@ -694,7 +694,7 @@ template ::value)> inline int printf(const S& format_str, const Args&... args) { internal::check_format_string(format_str); - typedef internal::basic_buffer buffer; + typedef internal::buffer buffer; typedef typename basic_printf_context_t::type context; format_arg_store as{args...}; return vprintf(to_string_view(format_str), basic_format_args(as)); @@ -704,7 +704,7 @@ template inline int vfprintf( std::basic_ostream& os, const S& format, basic_format_args< - typename basic_printf_context_t>::type> + typename basic_printf_context_t>::type> args) { basic_memory_buffer buffer; printf(buffer, to_string_view(format), args); @@ -726,7 +726,7 @@ template & os, const S& format_str, const Args&... args) { internal::check_format_string(format_str); - typedef internal::basic_buffer buffer; + typedef internal::buffer buffer; typedef typename basic_printf_context_t::type context; format_arg_store as{args...}; return vfprintf(os, to_string_view(format_str), diff --git a/include/format b/include/format index 9f482dc8..4576adbe 100644 --- a/include/format +++ b/include/format @@ -41,10 +41,10 @@ namespace std { template FMT_REQUIRES(OutputIterator) class basic_format_context; using format_context = basic_format_context< - /* unspecified */ std::back_insert_iterator>, + /* unspecified */ std::back_insert_iterator>, char>; using wformat_context = basic_format_context< - /* unspecified */ std::back_insert_iterator>, + /* unspecified */ std::back_insert_iterator>, wchar_t>; template struct formatter { @@ -686,8 +686,8 @@ template string vformat(string_view fmt, format_args args) { fmt::memory_buffer mbuf; - fmt::internal::buffer& buf = mbuf; - typedef fmt::back_insert_range range; + fmt::internal::buffer& buf = mbuf; + typedef fmt::back_insert_range> range; detail::format_handler, char, format_context> h(range(std::back_inserter(buf)), fmt, args, {}); fmt::internal::parse_format_string(fmt::to_string_view(fmt), h); diff --git a/src/format.cc b/src/format.cc index 585ab6c1..bb1aa627 100644 --- a/src/format.cc +++ b/src/format.cc @@ -11,7 +11,7 @@ FMT_BEGIN_NAMESPACE template struct internal::basic_data; // Workaround a bug in MSVC2013 that prevents instantiation of grisu2_format. -bool (*instantiate_grisu2_format)(double, internal::buffer&, int, bool, +bool (*instantiate_grisu2_format)(double, internal::buffer&, int, bool, int&) = internal::grisu2_format; #ifndef FMT_STATIC_THOUSANDS_SEPARATOR @@ -23,8 +23,7 @@ template FMT_API std::locale internal::locale_ref::get() const; template FMT_API char internal::thousands_sep_impl(locale_ref); -template FMT_API void internal::basic_buffer::append(const char*, - const char*); +template FMT_API void internal::buffer::append(const char*, const char*); template FMT_API void internal::arg_map::init( const basic_format_args& args); @@ -43,19 +42,20 @@ template FMT_API std::string internal::vformat( string_view, basic_format_args); template FMT_API format_context::iterator internal::vformat_to( - internal::buffer&, string_view, basic_format_args); + internal::buffer&, string_view, basic_format_args); -template FMT_API void internal::sprintf_format(double, internal::buffer&, +template FMT_API void internal::sprintf_format(double, internal::buffer&, core_format_specs); -template FMT_API void internal::sprintf_format(long double, internal::buffer&, +template FMT_API void internal::sprintf_format(long double, + internal::buffer&, core_format_specs); // Explicit instantiations for wchar_t. template FMT_API wchar_t internal::thousands_sep_impl(locale_ref); -template FMT_API void internal::basic_buffer::append(const wchar_t*, - const wchar_t*); +template FMT_API void internal::buffer::append(const wchar_t*, + const wchar_t*); template FMT_API void internal::arg_map::init( const basic_format_args&); diff --git a/test/core-test.cc b/test/core-test.cc index 31d4240b..6876ca32 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -31,7 +31,7 @@ using fmt::basic_format_arg; using fmt::string_view; -using fmt::internal::basic_buffer; +using fmt::internal::buffer; using fmt::internal::value; using testing::_; @@ -54,7 +54,7 @@ template struct formatter { return ctx.begin(); } - typedef std::back_insert_iterator> iterator; + typedef std::back_insert_iterator> iterator; auto format(test_struct, basic_format_context& ctx) -> decltype(ctx.out()) { @@ -66,28 +66,28 @@ FMT_END_NAMESPACE #if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 470 TEST(BufferTest, Noncopyable) { - EXPECT_FALSE(std::is_copy_constructible>::value); + EXPECT_FALSE(std::is_copy_constructible>::value); # if !FMT_MSC_VER // std::is_copy_assignable is broken in MSVC2013. - EXPECT_FALSE(std::is_copy_assignable>::value); + EXPECT_FALSE(std::is_copy_assignable>::value); # endif } TEST(BufferTest, Nonmoveable) { - EXPECT_FALSE(std::is_move_constructible>::value); + EXPECT_FALSE(std::is_move_constructible>::value); # if !FMT_MSC_VER // std::is_move_assignable is broken in MSVC2013. - EXPECT_FALSE(std::is_move_assignable>::value); + EXPECT_FALSE(std::is_move_assignable>::value); # endif } #endif // A test buffer with a dummy grow method. -template struct test_buffer : basic_buffer { +template struct test_buffer : buffer { void grow(std::size_t capacity) { this->set(FMT_NULL, capacity); } }; -template struct mock_buffer : basic_buffer { +template struct mock_buffer : buffer { MOCK_METHOD1(do_grow, void(std::size_t capacity)); void grow(std::size_t capacity) { @@ -133,7 +133,7 @@ TEST(BufferTest, VirtualDtor) { typedef StrictMock stict_mock_buffer; stict_mock_buffer* mock_buffer = new stict_mock_buffer(); EXPECT_CALL(*mock_buffer, die()); - basic_buffer* buffer = mock_buffer; + buffer* buffer = mock_buffer; delete buffer; } @@ -144,7 +144,7 @@ TEST(BufferTest, Access) { EXPECT_EQ(11, buffer[0]); buffer[3] = 42; EXPECT_EQ(42, *(&buffer[0] + 3)); - const basic_buffer& const_buffer = buffer; + const fmt::internal::buffer& const_buffer = buffer; EXPECT_EQ(42, const_buffer[3]); } @@ -293,7 +293,7 @@ VISIT_TYPE(float, double); { \ testing::StrictMock> visitor; \ EXPECT_CALL(visitor, visit(expected)); \ - typedef std::back_insert_iterator> iterator; \ + typedef std::back_insert_iterator> iterator; \ fmt::visit_format_arg( \ visitor, make_arg>(value)); \ } @@ -371,12 +371,12 @@ TEST(ArgTest, PointerArg) { struct check_custom { test_result operator()( fmt::basic_format_arg::handle h) const { - struct test_buffer : fmt::internal::basic_buffer { + struct test_buffer : fmt::internal::buffer { char data[10]; - test_buffer() : fmt::internal::basic_buffer(data, 0, 10) {} + test_buffer() : fmt::internal::buffer(data, 0, 10) {} void grow(std::size_t) {} } buffer; - fmt::internal::basic_buffer& base = buffer; + fmt::internal::buffer& base = buffer; fmt::format_parse_context parse_ctx(""); fmt::format_context ctx(std::back_inserter(base), fmt::format_args()); h.format(parse_ctx, ctx); diff --git a/test/custom-formatter-test.cc b/test/custom-formatter-test.cc index 6f16b4c1..d33b12f5 100644 --- a/test/custom-formatter-test.cc +++ b/test/custom-formatter-test.cc @@ -14,9 +14,10 @@ // A custom argument formatter that doesn't print `-` for floating-point values // rounded to 0. class custom_arg_formatter - : public fmt::arg_formatter> { + : public fmt::arg_formatter< + fmt::back_insert_range>> { public: - typedef fmt::back_insert_range range; + typedef fmt::back_insert_range> range; typedef fmt::arg_formatter base; custom_arg_formatter(fmt::format_context& ctx, diff --git a/test/format-test.cc b/test/format-test.cc index b3001255..1aa2e43e 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -20,8 +20,8 @@ # include #endif -#include "fmt/format.h" #include "fmt/color.h" +#include "fmt/format.h" #include "gmock.h" #include "gtest-extra.h" #include "mock-allocator.h" @@ -103,7 +103,7 @@ void std_format(long double value, std::wstring& result) { template ::testing::AssertionResult check_write(const T& value, const char* type) { fmt::basic_memory_buffer buffer; - typedef fmt::back_insert_range> range; + typedef fmt::back_insert_range> range; fmt::basic_writer writer(buffer); writer.write(value); std::basic_string actual = to_string(buffer); @@ -472,8 +472,8 @@ TEST(UtilTest, UTF16ToUTF8Convert) { } #endif // _WIN32 -typedef void (*FormatErrorMessage)(fmt::internal::buffer& out, int error_code, - string_view message); +typedef void (*FormatErrorMessage)(fmt::internal::buffer& out, + int error_code, string_view message); template void check_throw_error(int error_code, FormatErrorMessage format) { @@ -705,7 +705,8 @@ TEST(WriterTest, WriteUIntPtr) { memory_buffer buf; fmt::writer writer(buf); writer.write_pointer(fmt::internal::bit_cast( - reinterpret_cast(0xface)), FMT_NULL); + reinterpret_cast(0xface)), + FMT_NULL); EXPECT_EQ("0xface", to_string(buf)); } @@ -1948,7 +1949,7 @@ enum TestFixedEnum : short { B }; TEST(FormatTest, FixedEnum) { EXPECT_EQ("0", fmt::format("{}", B)); } #endif -typedef fmt::back_insert_range buffer_range; +typedef fmt::back_insert_range> buffer_range; class mock_arg_formatter : public fmt::internal::function< diff --git a/test/ostream-test.cc b/test/ostream-test.cc index a682e537..e60db62d 100644 --- a/test/ostream-test.cc +++ b/test/ostream-test.cc @@ -51,7 +51,7 @@ TEST(OStreamTest, Enum) { EXPECT_EQ(L"0", fmt::format(L"{}", A)); } -typedef fmt::back_insert_range range; +typedef fmt::back_insert_range> range; struct test_arg_formatter : fmt::arg_formatter { fmt::format_parse_context parse_ctx; @@ -61,7 +61,7 @@ struct test_arg_formatter : fmt::arg_formatter { TEST(OStreamTest, CustomArg) { fmt::memory_buffer buffer; - fmt::internal::buffer& base = buffer; + fmt::internal::buffer& base = buffer; fmt::format_context ctx(std::back_inserter(base), fmt::format_args()); fmt::format_specs spec; test_arg_formatter af(ctx, spec); @@ -134,7 +134,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) { std::streamsize max_streamsize = std::numeric_limits::max(); if (max_size <= fmt::internal::to_unsigned(max_streamsize)) return; - struct test_buffer : fmt::internal::buffer { + struct test_buffer : fmt::internal::buffer { explicit test_buffer(std::size_t size) { resize(size); } void grow(std::size_t) {} } buffer(max_size); diff --git a/test/ranges-test.cc b/test/ranges-test.cc index b8990717..acddd0d5 100644 --- a/test/ranges-test.cc +++ b/test/ranges-test.cc @@ -44,8 +44,8 @@ TEST(RangesTest, FormatPair) { } TEST(RangesTest, FormatTuple) { - std::tuple tu1{42, 1.5f, - "this is tuple", 'i'}; + std::tuple tu1{42, 1.5f, "this is tuple", + 'i'}; EXPECT_EQ("(42, 1.5, \"this is tuple\", 'i')", fmt::format("{}", tu1)); }