C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Replace an object -- but retain old object if new object fails to construct

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 30 Oct 2025 10:44:17 -0700
On Thursday, 30 October 2025 10:17:47 Pacific Daylight Time Sebastian Wittmeier
via Std-Proposals wrote:
> What is the disadvantage of using std::trivially_relocate()?

Unless it's guaranteed to be no-op for everyone, it requires extracting for
type-erasure, something we don't do now. And if it requires extracting for
*some* types, I need to know which types it is required for, so I don't have
to extract it for all types. Extracting unnecessarily creates more relocations
(used here in the old sense) in the binary, which slows down load time.

> Are there operations it does not support?
>
> Are the types not known when called?
>
> Would it definitely have less performance?

If it is not guaranteed to be a no-op, then by definition it may do something.
That is infinitely more work than no work. :-)

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2025-10-30 17:44:27