Reputation: 2068
What's the named cast equivalent for the following old-style cast?
const string *ps;
void *pv;
pv = (void*)ps; // <--- this
Is it pv = static_cast<void*>(const_cast<string*>(ps));
?
Upvotes: 2
Views: 397
Reputation:
pv = const_cast<string *>(ps);
is good enough - void *
is implicitly assignable from any (non-qualified) data (object) pointer type.
(Of course, for the same reason, a direct assignment to const void *
without any casting would work.)
Upvotes: 7