C++ Logo

std-proposals

Advanced search

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

From: Pavel Vazharov <freakpv_at_[hidden]>
Date: Thu, 15 Dec 2022 14:14:22 +0200
>
> 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();
}

Received on 2022-12-15 12:14:35