Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-02-28 11:56:08

Kevlin Henney <kevlin_at_[hidden]> writes:

> In message <uk727uuvv.fsf_at_[hidden]>, David Abrahams
> <dave_at_[hidden]> writes
>>>>The conversion to boost::any isn't a widening conversion in the usual
>>>>sense, though, is it? Normally, a widening conversion preserves not
>>>>only the information but the *interface* of the original data -- you
>>>>wouldn't consider an implicit conversion from int to string a widening
>>>>conversion, would you?
>>> Your assumption is not quite correct: most widening conversions are
>>> not interface preserving.
>>So you're saying it's not even a little correct, it sounds like. Can
>>you give some examples of non-interface-preserving widening
> 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?

Dave Abrahams
Boost Consulting

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