memcpy accepts two pointer parameters, one void* and the other const void* . The second parameter can be implicitly converted from the const char* argument (or another pointer-object-object-object-object), while the first cannot.
This lack of implicit conversion - this is the value - it forces the user to consciously discard the const in the (unlikely) event that they want, rather than accidentally discard it.
Then, as part of the implementation of memcpy or a similar function, the programmer would have to const_cast or C-style cast the const void* parameter before trying to change its referand. They will be able to static_cast non-constant parameter and change its referand. What type of throw you need to write, we hope, tells you something about what you do reasonably.
I think that if your helper functions shared_ptr should specifically handle void , then they will need to handle all cv-qualified void specially. So, there are four cases: void , const void , volatile void , const volatile void . But if function users in the past tried it on shared_ptr<void> and complained that it did not work, but never tried it on shared_ptr<const void> , then perhaps the problem did not occur.
Perhaps shared_ptr<void> already quite unusual that it did not appear. Maybe a person who uses shared_ptr<void> is inclined not to give up qualifying cv qualifiers, based on the fact that whenever someone ultimately restores the correct type, they also restore the correct qualifiers.
Think about it - does shared_ptr<const void> work, or does the code in shared_ptr that calls the deleter need an implicit conversion from T* to void* ? I don’t remember if I ever used shared_ptr<const T> .
Steve jessop
source share