Boost logo

Boost :

From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-09-04 04:41:52

In message <001201c015d9$5cfdd740$309a60cb_at_yogi>, Mark Rodgers
<mark.rodgers_at_[hidden]> writes
>> It already works for this case. The type check is performed using the
>> result of typeid rather than dynamic_cast: dynamic_cast<holder<const
>> int> *> would fail but typeid(int) == typeid(const int) is true, so it
>> works as it stands -- no deconsting through traits is required.
>Not OK. The way typeid strips off cv-qualifiers is the problem. Yes,
>this does compile, and works in probably 99% of cases, but the result
>is still undefined. As you note, the dynamic_cast would fail, which
>indicates that the static_cast is invalid. The remove_const is needed
>in the target type of the static_cast (in which case you could dispense
>with the typeid check and just use dynamic_cast).

I believe that the types are layout compatible, and so the problem does
not arise.

  Kevlin Henney phone: +44 117 942 2990
  Curbralan Ltd mobile: +44 7801 073 508
  kevlin_at_[hidden] fax: +44 870 052 2289

Boost list run by bdawes at, gregod at, cpdaniel at, john at