C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Idea: moved_from<T>() for Efficient Moved-From State Construction

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 24 Apr 2025 11:32:29 -0700
On Thursday, 24 April 2025 09:45:16 Pacific Daylight Time Jonathan Wakely via
Std-Proposals wrote:
> The ViewPort example is just dumb, nothing says he can't implement the
> cheap move. He offers two bad choices, and misses the obvious good
> solution. All you need is a ViewPort::valid() member that is false
> after being moved-from and then say valid() is a precondition for the
> other operations on it. What's so hard about that? There are **no
> performance implications**. Nothing says you need to ever test that
> valid() member anywhere in the other operations, because it's just a
> precondition that the caller is required to ensure is met.

Note the precondition is there whether valid() exists or not.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2025-04-24 18:32:30