Difference between revisions of "cpp/named req/Erasable"
(~) |
m (+C++11 in title; fmt) |
||
Line 1: | Line 1: | ||
− | {{cpp/named req/title|Erasable}} | + | {{cpp/named req/title|Erasable|notes={{mark since c++11}}}} |
{{cpp/named req/navbar}} | {{cpp/named req/navbar}} | ||
Line 7: | Line 7: | ||
The type {{ttb|T}} is {{named req|Erasable}} from the {{named req|Container}} {{ttb|X}} whose {{tt|value_type}} is identical to {{tt|T}} if, given | The type {{ttb|T}} is {{named req|Erasable}} from the {{named req|Container}} {{ttb|X}} whose {{tt|value_type}} is identical to {{tt|T}} if, given | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc | {{ttb|A}} | an allocator type}} | + | {{dsc|{{ttb|A}}|an allocator type}} |
− | {{dsc | {{ttb|m}} | an lvalue of type {{ttb|A}} }} | + | {{dsc|{{ttb|m}}|an lvalue of type {{ttb|A}}}} |
− | {{dsc | {{ttb|p}} | the pointer of type {{ttb|T*}} prepared by the container }} | + | {{dsc|{{ttb|p}}|the pointer of type {{ttb|T*}} prepared by the container }} |
{{dsc end}} | {{dsc end}} | ||
Line 26: | Line 26: | ||
{{rrev multi | {{rrev multi | ||
− | | until1=c++20 | rev1= | + | |until1=c++20|rev1= |
With the default allocator, this requirement is equivalent to the validity of {{c|p->~T()}}, which accepts class types with accessible destructors and all scalar types, but rejects array types, function types, reference types, and void. | With the default allocator, this requirement is equivalent to the validity of {{c|p->~T()}}, which accepts class types with accessible destructors and all scalar types, but rejects array types, function types, reference types, and void. | ||
− | | rev2= | + | |rev2= |
With the default allocator, this requirement is equivalent to the validity of {{c|std::destroy_at(p)}}, which accepts class types with accessible destructors and all scalar types, as well as arrays thereof. | With the default allocator, this requirement is equivalent to the validity of {{c|std::destroy_at(p)}}, which accepts class types with accessible destructors and all scalar types, as well as arrays thereof. | ||
}} | }} | ||
Line 36: | Line 36: | ||
===See also=== | ===See also=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc | {{named req|CopyInsertable}} }} | + | {{dsc|{{named req|CopyInsertable}}}} |
− | {{dsc | {{named req|MoveInsertable}} }} | + | {{dsc|{{named req|MoveInsertable}}}} |
− | {{dsc | {{named req|EmplaceConstructible}} }} | + | {{dsc|{{named req|EmplaceConstructible}}}} |
− | {{dsc | {{named req|Destructible}} }} | + | {{dsc|{{named req|Destructible}}}} |
{{dsc end}} | {{dsc end}} | ||
{{langlinks|de|es|ja|ru|zh}} | {{langlinks|de|es|ja|ru|zh}} |
Revision as of 12:15, 8 November 2022
Specifies that an object of the type can be destroyed by a given Allocator.
Requirements
The type T
is Erasable from the Container X
whose value_type
is identical to T
if, given
A
|
an allocator type |
m
|
an lvalue of type A
|
p
|
the pointer of type T* prepared by the container
|
where X::allocator_type
is identical to std::allocator_traits<A>::rebind_alloc<T>,
the following expression is well-formed:
std::allocator_traits<A>::destroy(m, p);
If X
is not allocator-aware or is a std::basic_string specialization, the term is defined as if A
were std::allocator<T>, except that no allocator object needs to be created, and user-defined specializations of std::allocator are not instantiated.
Notes
All standard library containers require that their element type satisfies Erasable.
With the default allocator, this requirement is equivalent to the validity of p->~T(), which accepts class types with accessible destructors and all scalar types, but rejects array types, function types, reference types, and void. |
(until C++20) |
With the default allocator, this requirement is equivalent to the validity of std::destroy_at(p), which accepts class types with accessible destructors and all scalar types, as well as arrays thereof. |
(since C++20) |
Although it is required that customized destroy
is used when destroying elements of std::basic_string until C++23, all implementations only used the default mechanism. The requirement is corrected by P1072R10 to match existing practice.
See also
CopyInsertable | |
MoveInsertable | |
EmplaceConstructible | |
Destructible |