Avoid -Wdangling-reference false positive in locale helpers (#4876)

This commit is contained in:
Vitalii Orazov 2026-08-05 18:05:22 +03:00 committed by GitHub
parent a245c6de99
commit 5f06f84835
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -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};

View File

@ -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());