[EMAIL PROTECTED] wrote:
   *Type*       info
*Title*         about operator >>= ( Any const &, SomeType & rhs )
*Posted by*     [EMAIL PROTECTED]
*Affected*      ...,
*Effective from*        => cws fwkpostbeta1



/*Summary*/


If operator >>= ( Any const &, SomeType & rhs ) returns false, then the right hand side argument has *not* been modified.



/*Description*/

Just because there has been confusion and a recent bug, I want to
recall that in case of an invalid >>= assignment, the right hand side
argument is *not* modified.

Valid assignments are most similar to what C++ compilers take without
warning, e.g. widening conversions without data loss. Some examples:

sal_Int32 n;
Any( static_cast<sal_Int8>(5) ) >>= n; // returns true: ok
Any(/*VOID*/) >>= n; // returns false: n still 5

For interfaces, the source object may be queried for the demanded
right hand side interface, e.g.

Reference<XFoo> x( ...;
Any(/*VOID*/) >>= x; // returns always false, x is untouched!

Any( Reference<XFoo>() ) >>= x; // returns true: x is cleared (null)
Mind that this is a valid assignment.
The operator does not signal whether the right hand reference is non-null!

Extracting a null reference of any interface type to a reference of any other interface type now succeeds (clears x and returns true), independent of the interface types involved. See <http://udk.openoffice.org/servlets/ReadMsg?list=dev&msgNo=2946>.


-Stephan

Any( Reference<XBar>(non-null) ) >>= x; // returns true if object
supports interface XFoo, else false (latter leaves x untouched which
has been fixed by issue 41709)

--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to