Код: Выделить всё
auto input = std::views::istream(std::wcin);
auto tokens = input | std::views::lazy_split(L' ');
for (auto const& token : tokens)
{
std::wstring s1(token); // doesn't compile
std::wstring s;
s = token; // doesn't compile
s = std::wstring(token); // doesn't compile
s = std::wstring{token.begin(), token.end()}; // doesn't compile
s = std::wstring(token.begin(), token.end()); // doesn't compile
s = std::wstring(token.cbegin(), token.cend()); // doesn't compile
// action goes here - requires the token to be a string
do_something_with_the_token_string(s);
}
Использование Visual Studio 17.9.1 с /std:c++20.
Подробнее здесь: https://stackoverflow.com/questions/780 ... h-stdviews
Мобильная версия