Hacking a SecureString based on std::basic_string for C++
The only thing special about SecureZeroMemory (the Windows version) is that it uses volatile to prevent optimization. Therefore there's no reason to write your own. Just defer to standard algorithms:

std::fill_n((volatile char*)p, n*sizeof(T), 0);


You will probably want to call the global delete:

::operator delete [] p;


Add noexcept:

template &lt;class U&gt; secure_allocator(const secure_allocator&lt;U&gt;&amp;) noexcept {}