From 939fbe5567c04cdaece6c379ab6400224f3ccb9d Mon Sep 17 00:00:00 2001 From: superfunc Date: Mon, 8 Oct 2018 09:30:27 -0700 Subject: [PATCH] Remove basic_fixed_buffer. Issue #873 indicates that this class is no longer required, as it has been superseded by a new API. Fixes #873 --- include/fmt/format-inl.h | 5 ----- include/fmt/format.h | 37 ------------------------------------- src/format.cc | 4 ---- test/format-test.cc | 23 ----------------------- 4 files changed, 69 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 51f4d2e8..c8a2e3a9 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -822,11 +822,6 @@ FMT_FUNC void format_system_error( format_error_code(out, error_code, message); } -template -void basic_fixed_buffer::grow(std::size_t) { - FMT_THROW(std::runtime_error("buffer overflow")); -} - FMT_FUNC void internal::error_handler::on_error(const char *message) { FMT_THROW(format_error(message)); } diff --git a/include/fmt/format.h b/include/fmt/format.h index 86f3dc1b..ed90f077 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -592,43 +592,6 @@ void basic_memory_buffer::grow(std::size_t size) { typedef basic_memory_buffer memory_buffer; typedef basic_memory_buffer wmemory_buffer; -/** - \rst - A fixed-size memory buffer. For a dynamically growing buffer use - :class:`fmt::basic_memory_buffer`. - - Trying to increase the buffer size past the initial capacity will throw - ``std::runtime_error``. - \endrst - */ -template -class basic_fixed_buffer : public internal::basic_buffer { - public: - /** - \rst - Constructs a :class:`fmt::basic_fixed_buffer` object for *array* of the - given size. - \endrst - */ - basic_fixed_buffer(Char *array, std::size_t size) { - this->set(array, size); - } - - /** - \rst - Constructs a :class:`fmt::basic_fixed_buffer` object for *array* of the - size known at compile time. - \endrst - */ - template - explicit basic_fixed_buffer(Char (&array)[SIZE]) { - this->set(array, SIZE); - } - - protected: - FMT_API void grow(std::size_t size) FMT_OVERRIDE; -}; - namespace internal { template diff --git a/src/format.cc b/src/format.cc index ab5663e1..bc8ac649 100644 --- a/src/format.cc +++ b/src/format.cc @@ -16,8 +16,6 @@ template FMT_API char internal::thousands_sep(locale_provider *lp); template void internal::basic_buffer::append(const char *, const char *); -template void basic_fixed_buffer::grow(std::size_t); - template void internal::arg_map::init( const basic_format_args &args); @@ -37,8 +35,6 @@ template FMT_API wchar_t internal::thousands_sep(locale_provider *); template void internal::basic_buffer::append( const wchar_t *, const wchar_t *); -template void basic_fixed_buffer::grow(std::size_t); - template void internal::arg_map::init( const basic_format_args &); diff --git a/test/format-test.cc b/test/format-test.cc index e48dedea..dd3ed739 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -351,29 +351,6 @@ TEST(MemoryBufferTest, ExceptionInDeallocate) { EXPECT_CALL(alloc, deallocate(&mem2[0], 2 * size)); } -TEST(FixedBufferTest, Ctor) { - char array[10] = "garbage"; - fmt::basic_fixed_buffer buffer(array, sizeof(array)); - EXPECT_EQ(static_cast(0), buffer.size()); - EXPECT_EQ(10u, buffer.capacity()); - EXPECT_EQ(array, buffer.data()); -} - -TEST(FixedBufferTest, CompileTimeSizeCtor) { - char array[10] = "garbage"; - fmt::basic_fixed_buffer buffer(array); - EXPECT_EQ(static_cast(0), buffer.size()); - EXPECT_EQ(10u, buffer.capacity()); - EXPECT_EQ(array, buffer.data()); -} - -TEST(FixedBufferTest, BufferOverflow) { - char array[10]; - fmt::basic_fixed_buffer buffer(array); - buffer.resize(10); - EXPECT_THROW_MSG(buffer.resize(11), std::runtime_error, "buffer overflow"); -} - #ifdef _WIN32 TEST(UtilTest, UTF16ToUTF8) { std::string s = "ёжик";