Difference between revisions of "cpp/named req/CopyAssignable"
From cppreference.com
m (r2.7.3) (Robot: Adding de, es, fr, it, ja, pt, ru, zh) |
Andreas Krug (Talk | contribs) m (fmt, .) |
||
(11 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | {{cpp/ | + | {{cpp/named req/title|CopyAssignable}} |
− | {{cpp/ | + | {{cpp/named req/navbar}} |
− | Specifies that an instance of the type can be copy-assigned | + | Specifies that an instance of the type can be copy-assigned from an [[cpp/language/value_category|lvalue expression]]. |
− | + | ||
− | + | ||
===Requirements=== | ===Requirements=== | ||
+ | The type {{tt|T}} satisfies {{named req/core|CopyAssignable}} if | ||
+ | * The type {{tt|T}} satisfies {{named req|MoveAssignable}}, and | ||
+ | Given | ||
+ | * {{tt|t}}, a modifiable [[cpp/language/value_category|lvalue expression]] of type {{tt|T}}, | ||
+ | * {{tt|v}}, an [[cpp/language/value_category|lvalue]] expression of type {{tt|T}} or {{tt|const T}} or an [[cpp/language/value_category|rvalue]] expression of type {{tt|const T}}. | ||
− | The | + | The following expressions must be valid and have their specified effects. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | { | + | {|table class=wikitable |
− | + | |- | |
− | + | !Expression||Return type||Return value||Post-conditions | |
− | + | |- | |
− | + | |{{c|1=t = v}} | |
+ | |{{tt|T&}} | ||
+ | |{{tt|t}} | ||
+ | |The value of {{tt|t}} is equivalent to the value of {{tt|v}}. | ||
+ | The value of {{tt|v}} is unchanged. | ||
+ | |} | ||
===See also=== | ===See also=== | ||
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc inc|cpp/types/dsc is_copy_assignable}} |
− | {{ | + | {{dsc inc|cpp/concepts/dsc assignable_from}} |
+ | {{dsc end}} | ||
− | + | {{langlinks|de|es|fr|it|ja|pt|ru|zh}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Latest revision as of 10:36, 8 August 2023
Specifies that an instance of the type can be copy-assigned from an lvalue expression.
[edit] Requirements
The type T
satisfies CopyAssignable if
- The type
T
satisfies MoveAssignable, and
Given
-
t
, a modifiable lvalue expression of typeT
, -
v
, an lvalue expression of typeT
orconst T
or an rvalue expression of typeconst T
.
The following expressions must be valid and have their specified effects.
Expression | Return type | Return value | Post-conditions |
---|---|---|---|
t = v | T&
|
t
|
The value of t is equivalent to the value of v .
The value of |
[edit] See also
(C++11)(C++11)(C++11) |
checks if a type has a copy assignment operator (class template) |
(C++20) |
specifies that a type is assignable from another type (concept) |