Date: Wed, 4 Jun 2025 10:08:30 +0100
On Wed, 4 Jun 2025, 09:03 Tymi via Std-Proposals, <
std-proposals_at_[hidden]> wrote:
> I find the move_as example more intuitive and generally "safer". Also my
> first thought was that std::string(std::move(c)) copied c._value and
> created a new object out of it, instead of just moving c._value.
>
You seem to be saying "moving" when you mean "casting to rvalue reference",
which is not moving.
I don't think your std:: expected example works, it didn't have a
conversion operator. What you want is just std:: move(*exp) or
*std::move(exp).
And your string example works with just static_cast<std::string&&>(obj).
So I think the existing solutions are fine.
std-proposals_at_[hidden]> wrote:
> I find the move_as example more intuitive and generally "safer". Also my
> first thought was that std::string(std::move(c)) copied c._value and
> created a new object out of it, instead of just moving c._value.
>
You seem to be saying "moving" when you mean "casting to rvalue reference",
which is not moving.
I don't think your std:: expected example works, it didn't have a
conversion operator. What you want is just std:: move(*exp) or
*std::move(exp).
And your string example works with just static_cast<std::string&&>(obj).
So I think the existing solutions are fine.
Received on 2025-06-04 09:08:47