Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
Description
A type is Assignable if it is possible to copy objects of that type and to assign values to variables.
Refinement Of
Associated Type(s)
Notation
XA type that is a model of Assignable
x, yObject of type X
Definitions
Valid Expressions
NameExpressionType requirementsReturn type
Copy constructorX(x) X
Copy constructor
X x(y);
X x = y;
  
Assignmentx = y [1] X&
Swapadobe::swap(x,y) void
Expression Semantics
NameExpressionPreconditionSemanticsPostcondition
Copy constructorX(x)  X(x) is a copy of x [2]
Copy constructorX(x)  X(x) is a copy of x [2]
Copy constructor
X x(y);
X x = y;
  x is a copy of y [2]
Assignmentx = y [1]  x is a copy of y [2]
Swapadobe::swap(x,y)[3] Equivalent to
{
  X tmp = x;
  x = y;
  y = tmp;
}
 
Complexity Guarantee(s)
Invariants
Type(s) Modeling this Concept
  • int
Notes
[1] One implication of this requirement is that a const type is not Assignable. For example, const int is not Assignable: if x is declared to be of type const int, then x = 7 is illegal. Similarly, the type pair<const int, int> is not Assignable.
[2] The reason this says "x is a copy of y", rather than "x == y", is that operator== is not necessarily defined: equality is not a requirement of Assignable. If the type X is EqualityComparable as well as Assignable, then a copy of x should compare equal to x.
See Also