mirror of
https://github.com/fmtlib/fmt.git
synced 2026-09-13 14:22:26 +08:00
Avoid -Wdangling-reference false positive in locale helpers (#4876)
This commit is contained in:
parent
a245c6de99
commit
5f06f84835
@ -129,7 +129,8 @@ inline void fwrite_all(const void* ptr, size_t count, FILE* stream) {
|
||||
|
||||
template <typename Char>
|
||||
FMT_FUNC auto thousands_sep_impl(locale_ref loc) -> thousands_sep_result<Char> {
|
||||
auto&& facet = use_facet<numpunct<Char>>(loc.get<locale>());
|
||||
auto loc_copy = loc.get<locale>();
|
||||
auto&& facet = use_facet<numpunct<Char>>(loc_copy);
|
||||
auto grouping = facet.grouping();
|
||||
auto thousands_sep = grouping.empty() ? Char() : facet.thousands_sep();
|
||||
return {std::move(grouping), thousands_sep};
|
||||
|
||||
@ -46,8 +46,8 @@ using format_string_char_t = typename format_string_char<S>::type;
|
||||
inline auto write_loc(basic_appender<wchar_t> out, loc_value value,
|
||||
const format_specs& specs, locale_ref loc) -> bool {
|
||||
#if FMT_USE_LOCALE
|
||||
auto& numpunct =
|
||||
std::use_facet<std::numpunct<wchar_t>>(loc.get<std::locale>());
|
||||
auto loc_copy = loc.get<std::locale>();
|
||||
auto& numpunct = std::use_facet<std::numpunct<wchar_t>>(loc_copy);
|
||||
auto separator = std::wstring();
|
||||
auto grouping = numpunct.grouping();
|
||||
if (!grouping.empty()) separator = std::wstring(1, numpunct.thousands_sep());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user