( T is the type of E1), this introduced a C-style castīitwise compound assignment operators for volatile types the expression E1 = was equivalent to E1 = T (E2 ).If the right operand is a braced-init-list If the left and the right operands identify overlapping objects, the behavior is undefined (unless the overlap is exact and the type is the same) When the left operand has reference type, the assignment operator modifies the referred-to object. The result is a bit-field if the left operand is a bit-field.įor non-class types, the right operand is first implicitly converted to the cv-unqualified type of the left operand, and then its value is copied into the object identified by left operand. The direct assignment operator expects a modifiable lvalue as its left operand and an rvalue expression or a braced-init-list (since C++11) as its right operand, and returns an lvalue identifying the left operand after modification. The direct assignment expressions have the formįor the built-in operator, lhs may have any non-const scalar type and rhs must be implicitly convertible to the type of lhs. For class types, this is a special member function, described in move assignment operator.įor non-class types, copy and move assignment are indistinguishable and are referred to as direct assignment.Ĭompound assignment operators replace the contents of the object a with the result of a binary operation between the previous value of a and the value of b. Move assignment operator replaces the contents of the object a with the contents of b, avoiding copying if possible ( b may be modified). For class types, this is a special member function, described in copy assignment operator. However, in a user-defined operator overload, any type can be used as return type (including void).Ĭopy assignment operator replaces the contents of the object a with a copy of the contents of b ( b is not modified). All built-in assignment operators return *this, and most user-defined overloads also return *this so that the user-defined operators can be used in the same manner as the built-ins.Member access operators: a, *a, &a, a->b, a.b, a->*b, a.*bĪssignment operators modify the value of the object. Increment and decrement: ++a, -a, a++, a. Value categories (lvalue, rvalue, xvalue)Ĭharacter literals including escape sequencesĪ=b, a+=b, a-=b, a*=b, a/=b, a%=b, a&=b, a|=b, a^=b, a>=b
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |