$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-09-02 03:28:01
In message <v03110700b5d5c82f6833@[153.32.222.4]>, Jesse Jones
<jejones_at_[hidden]> writes
>Here's the scenario I was thinking of.
[...]
>I have been using a struct that
>looks like this in the framework:
>
>struct SDocumentMesg {
> uint32 message;
> const void* data;
>};
>
>Client code could look like this:
>
>void ImageView::DoUpdate(const SDocumentMesg& mesg)
>{
> if (mesg.message == kChangedBits) {
> const XRect* area = reinterpret_cast<const XRect*>(mesg.data);
> this->Invalidate(*area);
> } else
> this->Invalidate(); // invalidate everything
>}
>
>Now I can replace the SDocumentMesg::mesg an any. But if I do this client
>code will break with no compiler warnings. Is this not a hole in the type
>system?
Fortunately, this doesn't compile, because a conversion is first
required from mesg.data to const void *, and then the conversion from
const void * to const XRect *. So, it's safe :-)
____________________________________________________________
Kevlin Henney phone: +44 117 942 2990
Curbralan Ltd mobile: +44 7801 073 508
kevlin_at_[hidden] fax: +44 870 052 2289
____________________________________________________________