C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Optimise stringstream to plunder a string

From: Peter C++ <peter.cpp_at_[hidden]>
Date: Thu, 15 Dec 2022 14:34:28 +0100
You are all welcome ! :-)

Peter

sent from a mobile device so please excuse strange words due to autocorrection.
Peter Sommerlad
peter.cpp_at_[hidden]
+41-79-432 23 32

> On 15 Dec 2022, at 13:39, Lénárd Szolnoki via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> Hi,
>
>> On 15 December 2022 12:14:22 GMT, Pavel Vazharov via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>>>
>>> I think istringstream should have an optimised method to assimilate an
>>> Rvalue string:
>>>
>>> We have such constructor already -
>> https://en.cppreference.com/w/cpp/io/basic_istringstream/basic_istringstream
>> (6)
>>
>> This code compiles and the program returns 1.
>>
>> #include <string>
>> #include <sstream>
>>
>> int main()
>> {
>> std::string str = "this is a very long string";
>> std::istringstream sstream(std::move(str));
>> return str.empty();
>> }
>
> The `str() &&` overload is also notable, so you can move out the string from a stringstream as well.
>
> Cheers,
> Lénárd
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2022-12-15 13:34:31