Date: Sun, 20 Apr 2025 18:37:42 +0200
Hi,
On 19/04/2025 21:26, Jeremy Rifkin via Std-Proposals wrote:
> (6)
> https://en.cppreference.com/w/cpp/string/basic_string_view/basic_string_view
>
> Cheers,
> Jeremy
Yes, but that constructor is explicit (used to be implicit; has been
made explicit by P2499R0). That means the code OP linked doesn't work.
One has to use something like:
transform([](auto &&word) { std::string_view v(word); /* use v */ })
Cf. also the example here: https://eel.is/c++draft/range.split.overview#3
And this rationale in P2210:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2210r2.html#what-should-the-reference-type-of-this-be
P1664 was exploring solutions in the area -- the very last motivational
example is precisely OP's issue:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1664r7.html#motivation
. AFAICS work on it has stalled.
>
>
> On 2025-04-19 13:45, 李 秋逸 via Std-Proposals wrote:
>> The code below is an error, that is strange.
>>
>> string str = /* ... */;
>> auto vw = str|split('.')|transform([](string_view sv){/* ... */});
>>
>> 获取Outlook for Android [1]
>>
>> Links:
>> ------
>> [1] https://aka.ms/AAb9ysg
Thank you,
--
Giuseppe D'Angelo
On 19/04/2025 21:26, Jeremy Rifkin via Std-Proposals wrote:
> (6)
> https://en.cppreference.com/w/cpp/string/basic_string_view/basic_string_view
>
> Cheers,
> Jeremy
Yes, but that constructor is explicit (used to be implicit; has been
made explicit by P2499R0). That means the code OP linked doesn't work.
One has to use something like:
transform([](auto &&word) { std::string_view v(word); /* use v */ })
Cf. also the example here: https://eel.is/c++draft/range.split.overview#3
And this rationale in P2210:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2210r2.html#what-should-the-reference-type-of-this-be
P1664 was exploring solutions in the area -- the very last motivational
example is precisely OP's issue:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1664r7.html#motivation
. AFAICS work on it has stalled.
>
>
> On 2025-04-19 13:45, 李 秋逸 via Std-Proposals wrote:
>> The code below is an error, that is strange.
>>
>> string str = /* ... */;
>> auto vw = str|split('.')|transform([](string_view sv){/* ... */});
>>
>> 获取Outlook for Android [1]
>>
>> Links:
>> ------
>> [1] https://aka.ms/AAb9ysg
Thank you,
--
Giuseppe D'Angelo
Received on 2025-04-20 16:37:48