I must apologize for my assertion, as I’ve found that const
isn’t always reliable. A value that might be modified by an API could very well be const
.
A typical example I’ve found so far is ArenaAllocator
. Not all of its members are pointers—its state member contains an end_index
, which is actually modified by the API ArenaAllocator.allocator().alloc
. However, because this modification is hidden by anyopaque
, this value, while actually mutable, can be defined as const
by the user without receiving an error.
Due to the widespread use of anyopaque
vtables, my assertion that using const
to determine whether a value is reliably copyable is unfounded.