C++ Logo

std-proposals

Advanced search

Re: [std-proposals] User-Defined Trivial Constructors

From: Peter Bindels <dascandy_at_[hidden]>
Date: Sat, 10 Jan 2026 18:54:00 +0100
Hi Jody,

On Sat, Jan 10, 2026 at 6:29 PM Jody Hagins <coachhagins_at_[hidden]> wrote:

> Hi Peter,
>
> Thanks for the feedback.
>
> I'm writing this off the top of my head, so forgive syntax issues.
>
> First, a terminology note: I'm talking about an "implicit-lifetime type,"
> not "trivial lifetime." This distinction matters — it's about whether an
> object's lifetime can begin *implicitly* (via `memcpy`, `mmap`,
> `start_lifetime_as`).
> <snip>
> Does this help clarify the problem and proposed solution?
>

Yes, completely.

I could have just said, "What Breno said."
>

No, I did not get this distinction from what he said. I was aware of
implicit lifetime types but didn't realize the rules were as you laid them
out. So:

- Implicit lifetime objects need a trivial constructor, but not necessarily
one that you can call, or that you actually do call
- std::atomic used to have that, but lost it in C++20
- We want the problem from pre-C++-20 fixed, but implicit lifetime back
- adding a do-nothing uncallable trivial constructor completely fixes it,
so we should do that

Correct?

If so, sounds good to me.

The specific example helps a lot to understand how it should work from a
user point of view.

Thanks,
Peter

Received on 2026-01-10 17:54:13