Merge branch 'master' of github.com:fmtlib/fmt
This commit is contained in:
commit
8d3fd86d6d
@ -11,7 +11,7 @@
|
||||
:alt: fmt is continuously fuzzed at oss-fuzz
|
||||
:target: https://bugs.chromium.org/p/oss-fuzz/issues/list?\
|
||||
colspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20\
|
||||
Summary&q=proj%3Dlibfmt&can=1
|
||||
Summary&q=proj%3Dfmt&can=1
|
||||
|
||||
.. image:: https://img.shields.io/badge/stackoverflow-fmt-blue.svg
|
||||
:alt: Ask questions at StackOverflow with the tag fmt
|
||||
@ -57,7 +57,7 @@ Features
|
||||
* Reliability: the library has an extensive set of `tests
|
||||
<https://github.com/fmtlib/fmt/tree/master/test>`_ and is `continuously fuzzed
|
||||
<https://bugs.chromium.org/p/oss-fuzz/issues/list?colspec=ID%20Type%20
|
||||
Component%20Status%20Proj%20Reported%20Owner%20Summary&q=proj%3Dlibfmt&can=1>`_
|
||||
Component%20Status%20Proj%20Reported%20Owner%20Summary&q=proj%3Dfmt&can=1>`_
|
||||
* Safety: the library is fully type safe, errors in format strings can be
|
||||
reported at compile time, automatic memory management prevents buffer overflow
|
||||
errors
|
||||
|
@ -761,7 +761,7 @@ class fixed_buffer_traits {
|
||||
|
||||
// A buffer that writes to an output iterator when flushed.
|
||||
template <typename OutputIt, typename T, typename Traits = buffer_traits>
|
||||
class iterator_buffer : public Traits, public buffer<T> {
|
||||
class iterator_buffer final : public Traits, public buffer<T> {
|
||||
private:
|
||||
OutputIt out_;
|
||||
enum { buffer_size = 256 };
|
||||
@ -787,7 +787,7 @@ class iterator_buffer : public Traits, public buffer<T> {
|
||||
size_t count() const { return Traits::count() + this->size(); }
|
||||
};
|
||||
|
||||
template <typename T> class iterator_buffer<T*, T> : public buffer<T> {
|
||||
template <typename T> class iterator_buffer<T*, T> final : public buffer<T> {
|
||||
protected:
|
||||
void grow(size_t) final FMT_OVERRIDE {}
|
||||
|
||||
@ -801,7 +801,7 @@ template <typename T> class iterator_buffer<T*, T> : public buffer<T> {
|
||||
template <typename Container>
|
||||
class iterator_buffer<std::back_insert_iterator<Container>,
|
||||
enable_if_t<is_contiguous<Container>::value,
|
||||
typename Container::value_type>>
|
||||
typename Container::value_type>> final
|
||||
: public buffer<typename Container::value_type> {
|
||||
private:
|
||||
Container& container_;
|
||||
@ -823,7 +823,7 @@ class iterator_buffer<std::back_insert_iterator<Container>,
|
||||
};
|
||||
|
||||
// A buffer that counts the number of code units written discarding the output.
|
||||
template <typename T = char> class counting_buffer : public buffer<T> {
|
||||
template <typename T = char> class counting_buffer final : public buffer<T> {
|
||||
private:
|
||||
enum { buffer_size = 256 };
|
||||
T data_[buffer_size];
|
||||
|
@ -651,7 +651,7 @@ enum { inline_buffer_size = 500 };
|
||||
*/
|
||||
template <typename T, size_t SIZE = inline_buffer_size,
|
||||
typename Allocator = std::allocator<T>>
|
||||
class basic_memory_buffer : public detail::buffer<T> {
|
||||
class basic_memory_buffer final : public detail::buffer<T> {
|
||||
private:
|
||||
T store_[SIZE];
|
||||
|
||||
|
@ -378,7 +378,7 @@ struct ostream_params {
|
||||
static constexpr detail::buffer_size buffer_size;
|
||||
|
||||
// A fast output stream which is not thread-safe.
|
||||
class ostream : private detail::buffer<char> {
|
||||
class ostream final : private detail::buffer<char> {
|
||||
private:
|
||||
file file_;
|
||||
|
||||
|
@ -78,7 +78,7 @@ TEST(BufferTest, Indestructible) {
|
||||
"buffer's destructor is protected");
|
||||
}
|
||||
|
||||
template <typename T> struct mock_buffer : buffer<T> {
|
||||
template <typename T> struct mock_buffer final : buffer<T> {
|
||||
MOCK_METHOD1(do_grow, size_t(size_t capacity));
|
||||
|
||||
void grow(size_t capacity) { this->set(this->data(), do_grow(capacity)); }
|
||||
@ -368,7 +368,7 @@ TEST(ArgTest, PointerArg) {
|
||||
struct check_custom {
|
||||
test_result operator()(
|
||||
fmt::basic_format_arg<fmt::format_context>::handle h) const {
|
||||
struct test_buffer : fmt::detail::buffer<char> {
|
||||
struct test_buffer final : fmt::detail::buffer<char> {
|
||||
char data[10];
|
||||
test_buffer() : fmt::detail::buffer<char>(data, 0, 10) {}
|
||||
void grow(size_t) {}
|
||||
|
@ -293,12 +293,8 @@ TEST(MemoryBufferTest, MoveAssignment) {
|
||||
|
||||
TEST(MemoryBufferTest, Grow) {
|
||||
typedef allocator_ref<mock_allocator<int>> Allocator;
|
||||
typedef basic_memory_buffer<int, 10, Allocator> Base;
|
||||
mock_allocator<int> alloc;
|
||||
struct TestMemoryBuffer : Base {
|
||||
TestMemoryBuffer(Allocator alloc) : Base(alloc) {}
|
||||
using Base::grow;
|
||||
} buffer((Allocator(&alloc)));
|
||||
basic_memory_buffer<int, 10, Allocator> buffer((Allocator(&alloc)));
|
||||
buffer.resize(7);
|
||||
using fmt::detail::to_unsigned;
|
||||
for (int i = 0; i < 7; ++i) buffer[to_unsigned(i)] = i * i;
|
||||
@ -306,7 +302,7 @@ TEST(MemoryBufferTest, Grow) {
|
||||
int mem[20];
|
||||
mem[7] = 0xdead;
|
||||
EXPECT_CALL(alloc, allocate(20)).WillOnce(Return(mem));
|
||||
buffer.grow(20);
|
||||
buffer.try_reserve(20);
|
||||
EXPECT_EQ(20u, buffer.capacity());
|
||||
// Check if size elements have been copied
|
||||
for (int i = 0; i < 7; ++i) EXPECT_EQ(i * i, buffer[to_unsigned(i)]);
|
||||
|
@ -150,7 +150,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
|
||||
std::streamsize max_streamsize = fmt::detail::max_value<std::streamsize>();
|
||||
if (max_size <= fmt::detail::to_unsigned(max_streamsize)) return;
|
||||
|
||||
struct test_buffer : fmt::detail::buffer<char> {
|
||||
struct test_buffer final : fmt::detail::buffer<char> {
|
||||
explicit test_buffer(size_t size)
|
||||
: fmt::detail::buffer<char>(nullptr, size, size) {}
|
||||
void grow(size_t) {}
|
||||
|
Loading…
Reference in New Issue
Block a user