components as the vector operand. The operation is performed component-wise
resulting in a same size vector.
8. The logical operators and (&&), or (||) operate on two Boolean expressions. The result is a
scalar or vector Boolean.
9. The logical unary operator not (!) operates on a Boolean expression. The result is a scalar
or vector Boolean.
10. The ternary selection operator (?:) operates on three expressions (
exp1
?
exp2
:
exp3
).
This operator evaluates the first expression
exp1
, which must result in a scalar Boolean.
If the result is
true
, it selects to evaluate the second expression; otherwise it evaluates
the third expression. Only one of the second and third expressions is evaluated. The
second and third expressions can be any type, as long their types match, or there is a
conversion in section 2.11 that can be applied to one of the expressions to make their
types match, or one is a vector and the other is a scalar in which case the scalar is
widened to the same type as the vector type. This resulting matching type is the type of
the entire expression.
11. The ones’ complement operator (~). The operand must be of a scalar or vector integer
type, and the result is the ones’ complement of its operand.
The operators right-shift (>>), left-shift (<<) operate on all scalar and vector integer types.
For built-in vector types, the operators are applied component-wise. For the right-shift (>>),
left-shift (<<) operators, if the first operand is a scalar, the rightmost operand must be a
scalar. If the first operand is a vector, the rightmost operand can be a vector or scalar.
The result of
E1 << E2
is
E1
left-shifted by
log2(N)
least significant bits in
E2
viewed as an
unsigned integer value, where
N
is the number of bits used to represent the data type of
E1
,
if
E1
is a scalar, or the number of bits used to represent the type of
E1
elements, if
E1
is a
vector. The vacated bits are filled with zeros.
The result of
E1 >> E2
is
E1
right-shifted by
log2(N)
least significant bits in
E2
viewed as
an unsigned integer value, where
N
is the number of bits used to represent the data type of
E1
, if
E1
is a scalar, or the number of bits used to represent the type of
E1
elements, if
E1
is
a vector. If
E1
has an unsigned type or if
E1
has a signed type and a nonnegative value, the
vacated bits are filled with zeros. If
E1
has a signed type and a negative value, the vacated
bits are filled with ones.
12. The assignment operator behaves as described by the C++14 Specification. For the
lvalue =
expression
assignment operation, if expression is a scalar type and lvalue is
a vector type, the scalar is converted to the element type used by the vector operand.
The scalar type is then widened to a vector that has the same number of components as
the vector operand. The operation is performed component-wise, which results in a
same size vector.
NOTE:
• Operators not described above that are supported by C++14 (such as
sizeof(T)
,
unary (&) operator, and comma (,) operator) behave as described in the C++14
Specification.
2017-9-12 | Copyright © 2017 Apple Inc. All Rights Reserved.
Page of
48
174