[cfe-commits] Better const_cast support
eli.friedman at gmail.com
Fri Sep 26 12:56:02 PDT 2008
On Fri, Sep 26, 2008 at 12:27 PM, Sebastian Redl
<sebastian.redl at getdesigned.at> wrote:
> Also, would it make sense to issue an extension warning? I wish comp.std.c++
> was active.
Possibly; not sure.
>>> + // Since we're dealing in canonical types, the remainder must be the
>>> + // FIXME: These must not be function or member function types.
>> This one is a little tricky... you have to watch out for cases where
>> the const gets cast off of a pointer type rather than the function
> Not really. The standard is pretty clear on this: no pointer to function, no
> matter how many levels of indirection, is allowed in a const_cast.
Take the following code:
typedef int f(int);
f*const fp = func;
f** fpp = const_cast<f**>(&fp);
f*const* is a pointer to a const-qualified object type, and f** is a
pointer to the corresponding non-const-qualified type.
Oh, and try to remember to use "Reply to all" when you're writing
responses on this mailing list; reply-to defaults to the sender, not
More information about the cfe-commits