diff --git a/include/fmt/format.h b/include/fmt/format.h index 685474f0..11a0669b 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -738,8 +738,9 @@ using is_double_double = bool_constant::digits == 106>; #endif // An allocator that uses malloc/free to allow removing dependency on the C++ -// standard libary runtime. -template struct allocator { +// standard libary runtime. std::decay is used for back_inserter to be found by +// ADL when applied to memory_buffer. +template struct allocator : private std::decay { using value_type = T; T* allocate(size_t n) { diff --git a/test/format-test.cc b/test/format-test.cc index e630ab0f..c0e1ea68 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -481,6 +481,12 @@ TEST(memory_buffer_test, max_size_allocator_overflow) { EXPECT_THROW(buffer.resize(161), std::exception); } +TEST(memory_buffer_test, back_insert_iterator) { + fmt::memory_buffer buf; + using iterator = decltype(std::back_inserter(buf)); + EXPECT_TRUE(fmt::detail::is_back_insert_iterator::value); +} + TEST(format_test, digits2_alignment) { auto p = fmt::detail::bit_cast(fmt::detail::digits2(0));