Boost logo

Boost :

From: Jesse Jones (jesjones_at_[hidden])
Date: 2000-09-02 17:15:23


>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 SDocumentMesg::data with 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 :-)

Why? There's only one user defined conversion happening so I would expect
it to compile. I just tried it with CodeWarrior 5.2 and it compiles....

  -- Jesse


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk