I'm trying to figure out when the standard allows using memset
.
cppreference claims that memset
can be used with trivially copyable types (modulo potentially overlapping subobjects — let's disregard those). The closest I could find while reading the standard (in particular, the C++17 draft publically available) is about memcpy
— indeed, there is a clause that explicitly allows copying the representation of a trivially copyable object into a char array and back, but that's about it.
In fact, looks like the standard doesn't even define the semantics of memset
with respect to the C++ entities it defines.
So, objects of which types am I allowed to memset
, what are the restrictions on the value I'm allowed to memset
them to and how to prove this?