All built-in operators return values, and most user-defined overloads also return values so that the user-defined operators can be used in the same manner as the built-ins. However, in a user-defined operator overload, any type can be used as return type (including void). In particular, stream insertion and stream extraction overloads of operator<< and operator>> return T&.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

T2 kann jeder Typ einschließlich T sein

Original:

T2 can be any type including T

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

If the operand passed to an arithmetic operator is integral or unscoped enumeration type, then before any other action (but after lvalue-to-rvalue conversion, if applicable), the operand undergoes ganzheitliche Förderung. If an operand has array or function type, array-to-pointer and function-to-pointer conversions are applied.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

For the binary operators (except shifts), if the promoted operands have different types, additional set of implicit conversions is applied, known as usual arithmetic conversions with the goal to produce the common type (also accessible via the std::common_type type trait)

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

Otherwise, the operand has integer type (because bool, char, char16_t, char32_t, wchar_t, and unscoped enumeration were promoted at this point) and integraler Konvertierungen are applied to produce the common type, as follows:

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

The conversion rank above increases in order bool, signedchar, short, int, long, longlong. The rank of any unsigned type is equal to the rank of the corresponding signed type. The rank of char is equal to the rank of signedchar and unsignedchar. The ranks of char16_t, char32_t, and wchar_t are equal to the ranks of their underlying types.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

Unsigned integer arithmetic is always performed modulo 2n where n is the number of bits in that particular integer. E.g. for unsignedint, adding one to UINT_MAX gives ​0​, and subtracting one from ​0​ gives UINT_MAX.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

When signed integer arithmetic operation overflows (the result does not fit in the result type), the behavior is undefined: it may wrap around according to the rules of the representation (typically 2's complement), it may trap on some platforms or due to compiler options (e.g. -ftrapv in GCC and Clang), or may be completely optimized out by the compiler.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

The builtin unary plus operator returns the value of its operand. The only situation where it is not a no-op is when the operand has integral type or unscoped enumeration type, which is changed by integral promotion, e.g, it converts char to int or if the operand is subject to lvalue-to-rvalue, array-to-pointer, or function-to-pointer conversion.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

With operands of arithmetic or enumeration type, the result of binary plus is the sum of the operands (after usual arithmetic converesions), and the result of the binary minus operator is the result of subtracting the second operand from the first (after usual arithmetic conversions).

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

Wenn einer der Operanden ein Zeiger ist, gelten die folgenden Regeln:

Original:

If any of the operands is a pointer, the following rules apply:

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

If the pointer P points to the ith element of an array, then the expressions P+n, n+P, and P-n are pointers of the same type that point to the i+nth, i+nth, and i-nth element of the same array, respectively. The result of pointer addition may also be a one-past-the-end pointer (that is, pointer P such that the expression P-1 points to the last element of the array). Any other situations (that is, attempts to generate a pointer that isn't pointing at an element of the same array or one past the end) invoke undefined behavior.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

If the pointer P points to the ith element of an array, and the pointer Q points at the jth element of the same array, the expression P-Q has the value i-j, if the value fits in std::ptrdiff_t. Both operands must point to the elements of the same array (or one past the end), otherwise the behavior is undefined. If the result does not fit in std::ptrdiff_t, the behavior is undefined.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

If the value ​0​ is added or subtracted from a pointer, the result is the pointer, unchanged. If two pointers point at the same object or are both one past the end of the same array, or both are null pointers, then the result of subtraction is equal to (std::ptrdiff_t)0.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

The binary operator / divides the first operand by the second (after usual arithmetic conversions).If the second operand is zero, the behavior is undefined. For integral operands, it yields the algebraic quotient

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

abgerundet durch die Implementierung definiert Richtung (bis C + +11)

Original:

rounded in implementation-defined direction (bis C + +11)

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

The binary operator % yields the remainder of the division of the first operand by the second (after usual arithmetic conversions). If the quotient a/b is representible in the result type, (a/b)*b + a%b == a. If the second operand is zero, the behavior is undefined.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

The operands of the built-in bitwise shift operators have either integral types or unscoped enumeration type. Integral promotions are performed on both operands before evaluation. The return type is the type of the left operand after integal promotions.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

For unsigned a, the value of a << b is the value of a * 2b, reduced modulo maximum value of the return type plus 1 (that is, bitwise left shift is performed and the bits that get shifted out of the destination type are discarded). For signed a, the value of a << b is a * 2b if it is representable by the return type, otherwise the behavior is undefined.

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

For unsigned a and for signed a with nonnegative values, the value of a >> b is the integer part of a/2b. For negative a, the value of a >> b is implementation-defined (in most implementations, this performs arithmetic right shift, so that the result remains negative)

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

Throughout the standard library, bitwise shift operators are commonly overloaded with I/O stream (std::ios_base& or one of the classes derived from it) as both the left operand and return type. Such operators are known as stream insertion and stream extraction operators:

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.