Boost logo

Boost :

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

>In message <v03110700b5d5c82f6833@[]>, 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*>(;
>> 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
>Fortunately, this doesn't compile, because a conversion is first
>required from 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, gregod at, cpdaniel at, john at