Next: , Up: Intrinsic Subprograms

5.1 Intrinsic Operators

All the predefined numeric operators in package Standard in pragma Import (Intrinsic,..) declarations. In the binary operator case, the operands must have the same size. The operand or operands must also be appropriate for the operator. For example, for addition, the operands must both be floating-point or both be fixed-point, and the right operand for "**" must have a root type of Standard.Integer'Base. You can use an intrinsic operator declaration as in the following example:

        type Int1 is new Integer;
        type Int2 is new Integer;
        function "+" (X1 : Int1; X2 : Int2) return Int1;
        function "+" (X1 : Int1; X2 : Int2) return Int2;
        pragma Import (Intrinsic, "+");

This declaration would permit “mixed mode” arithmetic on items of the differing types Int1 and Int2. It is also possible to specify such operators for private types, if the full views are appropriate arithmetic types.