Boost logo

Boost :

From: David Bergman (davidb_at_[hidden])
Date: 2004-02-28 14:39:16

Glen wrote:

> >I guess I don't understand the whole concept now. T* ->
> void* sounds
> >like "narrowing", since it loses information. int -> long
> never loses
> >information, so "widening" makes sense to me. What is the criterion?
> This is why I like C++'s choice of base and derived, there's
> never any confusion. You have the concepts of narrowing and
> widening correct but backwards. You narrow a type to a more
> specific derived type and widen one to a more general base type.

That is why we should always use "covariant" and "contravariant"
conversions, instead of (the proper but potentially confusing - if the
reader is in "number of bits" mode) "narrowing" and "widening."

This confusion leads to a shock when encountering the pointer-to-pointer
conversions in C++. One has to understand the oscillation between covariance
and contravariance when the indirections are traversed.

I will personally spam the next writer using "narrowing" or "widening" ;-)


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