memset_explicit For explanation have a look at C++ Proposal P1315R6. The code is tested with g++ 10.1.0 (C++17 standard). Additional information and comparision of possible approaches: Dead Store Elimination