What trait / concept can guarantee memsetting an object is well defined?
问题 Let's say I have defined a zero_initialize() function: template<class T> T zero_initialize() { T result; std::memset(&result, 0, sizeof(result)); return result; } // usage: auto data = zero_initialize<Data>(); Calling zero_initialize() for some types would lead to undefined behavior 1, 2 . I'm currently enforcing T to verify std::is_pod. With that trait being deprecated in C++20 and the coming of concepts, I'm curious how zero_initialize() should evolve. What (minimal) trait / concept can