Difference between revisions of "cpp/named req/MoveInsertable"
(clarify) |
(Fix typo ('copied into', not 'copied in')) |
||
Line 2: | Line 2: | ||
{{cpp/concept/navbar}} | {{cpp/concept/navbar}} | ||
− | Specifies that a rvalue of the type can be copied | + | Specifies that a rvalue of the type can be copied into uninitialized storage. |
===Requirements=== | ===Requirements=== |
Revision as of 20:18, 2 October 2015
Template:cpp/concept/title Template:cpp/concept/navbar
Specifies that a rvalue of the type can be copied into uninitialized storage.
Requirements
The type T
is Template:concept into the Template:concept X
if, given
A
|
the allocator type defined as X::allocator_type
|
m
|
the lvalue of type A obtained from X::get_allocator()
|
p
|
the pointer of type T* prepared by the container
|
rv
|
rvalue expression of type T , provided as the argument to push_back(), etc
|
the following expression is well-formed:
std::allocator_traits<A>::construct(m, p, rv);
And after evaluation, the value of *p
is equivalent to the value formerly held by rv
(rv
remains valid, but unspecified)
Notes
If A
is std::allocator<T>, then this will call placement-new, as by ::new((void*)p) T(rv).
If std::allocator<T> or a similar allocator is used, a class does not have to implement a move constructor to satisfy this type requirement: a copy constructor that takes a const T&
argument can bind rvalue expressions. If a MoveInsertable class implements a move constructor, it may also implement move semantics to take advantage of the fact that the value of rv
after construction is unspecified.
See Also
Template:concept |