Cleanup
This commit is contained in:
@@ -1,28 +1,22 @@
|
||||
/*
|
||||
Custom argument formatter tests
|
||||
// Formatting library for C++ - custom argument formatter tests
|
||||
//
|
||||
// Copyright (c) 2012 - present, Victor Zverovich
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
Copyright (c) 2016, Victor Zverovich
|
||||
All rights reserved.
|
||||
|
||||
For the license information refer to format.h.
|
||||
*/
|
||||
|
||||
#include "fmt/printf.h"
|
||||
#include "fmt/format.h"
|
||||
#include "gtest-extra.h"
|
||||
|
||||
using fmt::printf_arg_formatter;
|
||||
|
||||
// A custom argument formatter that doesn't print `-` for floating-point values
|
||||
// rounded to 0.
|
||||
class CustomArgFormatter :
|
||||
class custom_arg_formatter :
|
||||
public fmt::arg_formatter<fmt::back_insert_range<fmt::internal::buffer>> {
|
||||
public:
|
||||
typedef fmt::back_insert_range<fmt::internal::buffer> range;
|
||||
typedef decltype(fmt::internal::declval<range>().begin()) iterator;
|
||||
typedef fmt::arg_formatter<range> base;
|
||||
|
||||
CustomArgFormatter(fmt::basic_context<iterator, char> &ctx,
|
||||
fmt::format_specs &s)
|
||||
custom_arg_formatter(fmt::context &ctx, fmt::format_specs &s)
|
||||
: base(ctx, s) {}
|
||||
|
||||
using base::operator();
|
||||
@@ -37,7 +31,7 @@ class CustomArgFormatter :
|
||||
std::string custom_vformat(fmt::string_view format_str, fmt::format_args args) {
|
||||
fmt::memory_buffer buffer;
|
||||
// Pass custom argument formatter as a template arg to vwrite.
|
||||
fmt::vformat_to<CustomArgFormatter>(buffer, format_str, args);
|
||||
fmt::vformat_to<custom_arg_formatter>(buffer, format_str, args);
|
||||
return std::string(buffer.data(), buffer.size());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user