diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-01-23 15:35:29 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2024-02-01 15:26:53 +0000 |
commit | e81a69757720158fee81fc282cae02c4c82ab672 (patch) | |
tree | c33e95b53f66778de355abbc88d7d12d72ef415f /libstdc++-v3 | |
parent | a5eb246e04d08ee6d7de06a2389fc3b541ecdde9 (diff) | |
download | gcc-e81a69757720158fee81fc282cae02c4c82ab672.zip gcc-e81a69757720158fee81fc282cae02c4c82ab672.tar.gz gcc-e81a69757720158fee81fc282cae02c4c82ab672.tar.bz2 |
libstdc++: Fix -Wdeprecated warning about implicit capture of 'this'
In C++20 it's deprecated for a [=] lambda capture to capture the 'this'
pointer. Using resize_and_overwrite with a lambda seems like overkill to
write three chars to the string anyway. Just resize the string and
overwrite the end of it directly.
libstdc++-v3/ChangeLog:
* include/experimental/internet (network_v4::to_string()):
Remove lambda and use of resize_and_overwrite.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/include/experimental/internet | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/libstdc++-v3/include/experimental/internet b/libstdc++-v3/include/experimental/internet index f04163d..82043c8 100644 --- a/libstdc++-v3/include/experimental/internet +++ b/libstdc++-v3/include/experimental/internet @@ -1314,20 +1314,12 @@ namespace ip { auto __str = address().to_string(__a); const unsigned __addrlen = __str.length(); - const unsigned __preflen = prefix_length() >= 10 ? 2 : 1; - auto __write = [=](char* __p, size_t __n) { - __p[__addrlen] = '/'; - std::__detail::__to_chars_10_impl(__p + __addrlen + 1, __preflen, - (unsigned char)prefix_length()); - return __n; - }; - const unsigned __len = __addrlen + 1 + __preflen; -#if __cpp_lib_string_resize_and_overwrite - __str.resize_and_overwrite(__len, __write); -#else - __str.resize(__len); - __write(&__str.front(), __len); -#endif + const unsigned __preflenlen = _M_prefix_len >= 10 ? 2 : 1; + __str.resize(__addrlen + 1 + __preflenlen); + __str[__addrlen] = '/'; + std::__detail::__to_chars_10_impl(&__str.front() + __addrlen + 1, + __preflenlen, + (unsigned char)_M_prefix_len); return __str; } |