C++ Logo

std-proposals

Advanced search

Re: [std-proposals] <type_traits> std::contains_mutable

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 14 Nov 2025 14:23:42 -0800
On Friday, 14 November 2025 11:18:57 Pacific Standard Time Thiago Macieira via
Std-Proposals wrote:
> You can change permissions on pages, sure. But imagine that the page was
> read- only for a reason, such as a DAX/Flash mapped file from read-only
> storage. If did make that page writable and the OS wasn't prepared to do
> copy-on-write, you'd still get a crash for writing to the page: the MMU
> would attempt to write, but the actual backing device wouldn't allow it.

Though after thinking a little more about it, I could find use for this.

I have, in the past, put some structs in read-only shared memory. My code only
static_asserts that it is trivially_copyable and trivially_destructible,
ensuring it contains no mutable could be useful too. But incomplete: that also
requires ensuring there are no *pointers*.

But the use-cases are very, very niche.

You can see my code here:
https://github.com/opendcdiag/opendcdiag/blob/main/framework/
sandstone_p.h#L557-L558
https://github.com/opendcdiag/opendcdiag/blob/main/framework/
sandstone.cpp#L965-L1038

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

Received on 2025-11-14 22:23:50