RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomVariantType.RightPromotion Method

Indicates whether the right argument to a binary operation should be coerced to a different type.

Pascal
function RightPromotion(const V: TVarData; const Operator: TVarOp; out RequiredVarType: TVarType): Boolean; virtual;
C++
virtual __fastcall Boolean RightPromotion(const TVarData V, const TVarOp Operator, TVarType RequiredVarType);

Override RightPromotion to indicate when the right-hand argument for a binary or comparison operation should be implicitly cast to another type before performing the operation. RightPromotion is called when the right-hand System::Variant in a binary or comparison operation is of this System::Variant type.

Note: In operations that involve two custom Variants, the left-hand argument's RightPromotion method is called first. The right-hand argument's LeftPromotion method is then called only if the left-hand argument's RightPromotion method returns false.
V is the TVarData record for the left-hand argument of the operation. 

Operator indicates the type of operation. It can be any of the operators in the following table:

Value 
Operation 
opAdd  
addition  
subtraction  
multiplication  
floating-point division  
integer division  
remainder  
right shift  
right shift  
opAnd  
bitwise and  
opOr  
bitwise or  
opXor  
bitwise exclusive or  
any comparison operation  

RequiredVarType returns the System::Variant type code for the type to which the right-hand argument should be cast before performing the operation. If the operation can proceed with the right-hand argument left as-is, RequiredVarType returns the VType field of V. 

RightPromotion returns true if the TCustomVariantType descendant can perform the operation (using the BinaryOp, CompareOp, or Compare method) assuming the right-hand argument can be cast to RequiredVarType. It returns false if the TCustomVariantType descendant can't perform the operation. 

As implemented in TCustomVariantType, RightPromotion returns the VarType property as RequiredVarType, and returns true. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!