
In message <uptbzrvmf.fsf@boost-consulting.com>, David Abrahams <dave@boost-consulting.com> writes
T * to void *, derived * to base *, int (32 bit) to double (64 bit), T * to const T *, etc. Widening conversions are in the direction of the supertype, hence they often have a subset of the interface of source type. The corresponding narrowing of the interface with the widening of the type is not always the case, eg an int to long is effectively interface preserving -- the same set of operators is supported for both types.
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?
All widening conversions lose type (ie interface and usage) information as a trade for widening the range or number of things that they can refer to. In the case of int to long, you have lost the information that it was originally an int, and could fit into an int. In the case of derived * to base * you have lost the information that you were pointing to something that was at least a derived. In the case of T * to void * you have lost the information that you were dealing with something that was at least a T. In both cases we are dealing with "individuals" and we are widening the range or number of individuals we can deal with or refer to. In the int-to-long case we are dealing with values, so the notion of set containment and its relationship to the widen/narrow metaphor is most obvious here. When dealing with pointers we tend to focus on the entities that we are referring to, rather than on the pointer value itself. A void * can refer to a larger set of objects than a given T *, a base * can refer to a larger set of objects than a derived *. However, the same conclusion can be reached by considering the pointers as values rather than as handles to entities: there are more legal values that a void * can take in a program than a T *. Hope that clarifies the terminology. Kevlin -- ____________________________________________________________ Kevlin Henney phone: +44 117 942 2990 mailto:kevlin@curbralan.com mobile: +44 7801 073 508 http://www.curbralan.com fax: +44 870 052 2289 Curbralan: Consultancy + Training + Development + Review ____________________________________________________________