title: Template to perform automatic memory overwrite on destruction
body: <p>It is a common pattern to use templates to enforce the compiler to initialize primitive / POD types values (<a href="https://stackoverflow.com/a/11493744/16673">https://stackoverflow.com/a/11493744/16673</a> or <a href="http://www.codeproject.com/Articles/825/Using-templates-for-initialization" rel="nofollow noreferrer">http://www.codeproject.com/Articles/825/Using-templates-for-initialization</a>).</p>
  
  <p>Does a similar pattern exist that could be used to erase the value once it goes out of scope for security reasons, to make sure the value is not left on the stack once the variable is destructed? I am afraid a naive analogous implementation might not work, as the compiler is free to ignore any assignments to a value which is going out of scope, as the value can be trivially proven not to be used any more. Is there some consistent and reasonably portable solution e.g. using volatile?</p>