System.Variants.TCustomVariantType.LeftPromotion

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function LeftPromotion(const V: TVarData; const Operator: TVarOp;  out RequiredVarType: TVarType): Boolean; virtual;

C++

virtual bool __fastcall LeftPromotion(const TVarData &V, const int Operator, /* out */ System::Word &RequiredVarType);

Properties

Type Visibility Source Unit Parent
function protected
System.Variants.pas
System.Variants.hpp
System.Variants TCustomVariantType

Description

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

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

  • The left-hand argument is a built-in Variant type.
  • The left-hand argument is a custom Variant type that does not indicate any problem with this Variant type for the right-hand argument.

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

opSubtract

subtraction

opMultiply

multiplication

opDivide

floating-point division

opIntDivide

integer division

opModulus

remainder

opShiftLeft

left shift

opShiftRight

right shift

opAnd

bitwise and

opOr

bitwise or

opXor

bitwise exclusive or

opCompare

any comparison operation


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

LeftPromotion returns True if the TCustomVariantType descendant can perform the operation (using the BinaryOp, CompareOp, or Compare method) assuming the left-hand argument can be cast to RequiredVarType. It returns False if the TCustomVariantType descendant cannot perform the operation.

As implemented in TCustomVariantType, LeftPromotion returns the VarType property as RequiredVarType, and returns True.

See Also