C++ Logo

std-proposals

Advanced search

Re: [std-proposals] move_as

From: Tymi <tymi.cpp_at_[hidden]>
Date: Wed, 4 Jun 2025 10:03:36 +0200
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.

Tymi.

On Wed, Jun 4, 2025 at 10:01 AM Jan Schultke <janschultke_at_[hidden]>
wrote:

> > const auto myString = std::move_as<std::string>(c);
>
> This seems more verbose and hard to reason about than the existing:
>
> > const auto myString = std::string(std::move(c));
>

Received on 2025-06-04 08:03:46