C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Fri, 14 Nov 2025 15:59:48 +0000
On Fri, Nov 14, 2025 at 3:13 PM David Brown wrote:
>
> Flash is almost never directly writeable at run-time. Special
> procedures, well outside the scope of the C++ standards, are used to
> erase and write flash memory. There are certain other types of
> non-volatile memory that can be written directly, but not flash.



In my last job programming microscopes, there was a Texas Instruments
microcontroller connected by I2C to an Arduino microcontroller.

I wrote a program for the Texas to send packets over I2C containing a
firmware upgrade for the Arduino.
I wrote a program for the Arduino to receive packets over I2C and to
write to its own Flash.

I got this working. Arduino's can write to their own Flash at runtime
(so long as you don't overwrite the machine code that's currently
being executed). Or at least the SAMD21 can. Maybe others can't.



> const objects that do not have static storage duration and program
> lifetimes, cannot be placed in flash because their address and contents
> are not fixed when the program image is created (i.e., at compile/link
> time).



I'm talking about the programmer deliberately placing a const object
in the Flash at a known address.

Like if the flash is from 0x2000 to 0x8000, then at runtime I can
store an object at 0x4000. Later after I reset the microcontroller,
that object will still be there at address 0x4000 and I can invoke
const methods on it -- just so long as it doesn't contain any
mutables.

But I'm not only talking about microcontrollers here. On desktop PC's,
you can create an object and then change the permissions on the page
of memory to read-only.

Received on 2025-11-14 16:00:00