Commit fbc38b90 authored by Victor Zverovich's avatar Victor Zverovich

Pass heavy arguments by ref

parent 8dc69b9d
...@@ -720,7 +720,7 @@ class basic_format_arg { ...@@ -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 {}; ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment