Re: [gtkmm] Re: pthreads with gtk/gtkmm

>> >> void *test(void *arg){
>> >>   Args *a = (Args *) arg;
>> >You should really use static_cast<Args *>(arg) here.
>> nope. reinterpret_cast<Args*>(arg). static_cast is used when casting
>> from child to parent within a class heirarchy.
>Hm, who says that?
>I use dynamic_cast for class stuff and static_cast for
>straight-forward data-type conversion. There was only one case where
>I had to use reinterpret_cast, and that was because gcc-3.2 doesn't
>want to convert char->uchar and vice versa without it.

wel, i just took a look at stroustroup 3rd edition. what he says there
is bit unclear. its apparent that reinterpret_cast<> is the
"strongest" form of casting, useful such as where casting between
pointers and integers (p.256). however, on page 413, static_cast<> is
used to cast from a void pointer, in the context of explaining why you
cannot use dynamic_cast<> for this.

i follow the guideline i outlined above because it appears to me that
any cast from void * to anything at all is 100% dangerous, and using
static_cast<> suggests that it is somehow "safe" when in fact it is


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]