mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 02:37:36 +02:00
Pass heavy arguments by ref
This commit is contained in:
@ -720,7 +720,7 @@ class basic_format_arg {
|
|||||||
|
|
||||||
template <typename Visitor, typename Ctx>
|
template <typename Visitor, typename Ctx>
|
||||||
friend FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type
|
friend FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type
|
||||||
visit(Visitor &&vis, basic_format_arg<Ctx> arg);
|
visit(Visitor &&vis, const basic_format_arg<Ctx> &arg);
|
||||||
|
|
||||||
friend class basic_format_args<Context>;
|
friend class basic_format_args<Context>;
|
||||||
friend class internal::arg_map<Context>;
|
friend class internal::arg_map<Context>;
|
||||||
|
@ -1165,7 +1165,7 @@ struct monostate {};
|
|||||||
*/
|
*/
|
||||||
template <typename Visitor, typename Context>
|
template <typename Visitor, typename Context>
|
||||||
FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type
|
FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type
|
||||||
visit(Visitor &&vis, basic_format_arg<Context> arg) {
|
visit(Visitor &&vis, const basic_format_arg<Context> &arg) {
|
||||||
typedef typename Context::char_type char_type;
|
typedef typename Context::char_type char_type;
|
||||||
switch (arg.type_) {
|
switch (arg.type_) {
|
||||||
case internal::none_type:
|
case internal::none_type:
|
||||||
@ -2405,7 +2405,7 @@ class basic_writer {
|
|||||||
// <left-padding><value><right-padding>
|
// <left-padding><value><right-padding>
|
||||||
// where <value> is written by f(it).
|
// where <value> is written by f(it).
|
||||||
template <typename F>
|
template <typename F>
|
||||||
void write_padded(std::size_t size, const align_spec &spec, F f);
|
void write_padded(std::size_t size, const align_spec &spec, F &&f);
|
||||||
|
|
||||||
template <typename F>
|
template <typename F>
|
||||||
struct padded_int_writer {
|
struct padded_int_writer {
|
||||||
@ -2755,7 +2755,7 @@ class basic_writer {
|
|||||||
template <typename Range>
|
template <typename Range>
|
||||||
template <typename F>
|
template <typename F>
|
||||||
void basic_writer<Range>::write_padded(
|
void basic_writer<Range>::write_padded(
|
||||||
std::size_t size, const align_spec &spec, F f) {
|
std::size_t size, const align_spec &spec, F &&f) {
|
||||||
unsigned width = spec.width();
|
unsigned width = spec.width();
|
||||||
if (width <= size)
|
if (width <= size)
|
||||||
return f(reserve(size));
|
return f(reserve(size));
|
||||||
@ -3250,7 +3250,8 @@ class dynamic_formatter {
|
|||||||
|
|
||||||
template <typename Range, typename Char>
|
template <typename Range, typename Char>
|
||||||
typename basic_format_context<Range, Char>::format_arg
|
typename basic_format_context<Range, Char>::format_arg
|
||||||
basic_format_context<Range, Char>::get_arg(basic_string_view<char_type> name) {
|
basic_format_context<Range, Char>::get_arg(
|
||||||
|
basic_string_view<char_type> name) {
|
||||||
map_.init(this->args());
|
map_.init(this->args());
|
||||||
format_arg arg = map_.find(name);
|
format_arg arg = map_.find(name);
|
||||||
if (arg.type() == internal::none_type)
|
if (arg.type() == internal::none_type)
|
||||||
|
Reference in New Issue
Block a user