capture of this: support C++14 & C++20 via macro
This commit is contained in:
parent
818f65e30a
commit
91251b9069
@ -172,6 +172,12 @@ FMT_END_NAMESPACE
|
|||||||
# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
|
# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (__cplusplus >= 201703L)
|
||||||
|
# define FMT_CAPTURE_OF_THIS , this
|
||||||
|
#else
|
||||||
|
# define FMT_CAPTURE_OF_THIS
|
||||||
|
#endif
|
||||||
|
|
||||||
// Some compilers masquerade as both MSVC and GCC-likes or otherwise support
|
// Some compilers masquerade as both MSVC and GCC-likes or otherwise support
|
||||||
// __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the
|
// __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the
|
||||||
// MSVC intrinsics if the clz and clzll builtins are not available.
|
// MSVC intrinsics if the clz and clzll builtins are not available.
|
||||||
@ -1467,10 +1473,10 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
|
|||||||
|
|
||||||
void on_dec() {
|
void on_dec() {
|
||||||
auto num_digits = count_digits(abs_value);
|
auto num_digits = count_digits(abs_value);
|
||||||
out =
|
out = write_int(out, num_digits, get_prefix(), specs,
|
||||||
write_int(out, num_digits, get_prefix(), specs, [=, this](iterator it) {
|
[= FMT_CAPTURE_OF_THIS](iterator it) {
|
||||||
return format_decimal<Char>(it, abs_value, num_digits);
|
return format_decimal<Char>(it, abs_value, num_digits);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_hex() {
|
void on_hex() {
|
||||||
@ -1479,11 +1485,11 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
|
|||||||
prefix[prefix_size++] = specs.type;
|
prefix[prefix_size++] = specs.type;
|
||||||
}
|
}
|
||||||
int num_digits = count_digits<4>(abs_value);
|
int num_digits = count_digits<4>(abs_value);
|
||||||
out =
|
out = write_int(out, num_digits, get_prefix(), specs,
|
||||||
write_int(out, num_digits, get_prefix(), specs, [=, this](iterator it) {
|
[= FMT_CAPTURE_OF_THIS](iterator it) {
|
||||||
return format_uint<4, Char>(it, abs_value, num_digits,
|
return format_uint<4, Char>(it, abs_value, num_digits,
|
||||||
specs.type != 'x');
|
specs.type != 'x');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_bin() {
|
void on_bin() {
|
||||||
@ -1492,10 +1498,10 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
|
|||||||
prefix[prefix_size++] = static_cast<char>(specs.type);
|
prefix[prefix_size++] = static_cast<char>(specs.type);
|
||||||
}
|
}
|
||||||
int num_digits = count_digits<1>(abs_value);
|
int num_digits = count_digits<1>(abs_value);
|
||||||
out =
|
out = write_int(out, num_digits, get_prefix(), specs,
|
||||||
write_int(out, num_digits, get_prefix(), specs, [=, this](iterator it) {
|
[= FMT_CAPTURE_OF_THIS](iterator it) {
|
||||||
return format_uint<1, Char>(it, abs_value, num_digits);
|
return format_uint<1, Char>(it, abs_value, num_digits);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_oct() {
|
void on_oct() {
|
||||||
@ -1505,10 +1511,10 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
|
|||||||
// is not greater than the number of digits.
|
// is not greater than the number of digits.
|
||||||
prefix[prefix_size++] = '0';
|
prefix[prefix_size++] = '0';
|
||||||
}
|
}
|
||||||
out =
|
out = write_int(out, num_digits, get_prefix(), specs,
|
||||||
write_int(out, num_digits, get_prefix(), specs, [=, this](iterator it) {
|
[= FMT_CAPTURE_OF_THIS](iterator it) {
|
||||||
return format_uint<3, Char>(it, abs_value, num_digits);
|
return format_uint<3, Char>(it, abs_value, num_digits);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { sep_size = 1 };
|
enum { sep_size = 1 };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user