std::basic_string<CharT,Traits,Allocator>::clear
cppreference.com
<tbody>
</tbody>
<tbody class="t-dcl-rev ">
</tbody><tbody>
</tbody>
void clear(); |
( C++11) | |
void clear() noexcept; |
( C++11) ( C++20) |
|
constexpr void clear() noexcept; |
( C++20) | |
, erase(begin(), end()).
, .
()
()
std::vector::clear, C++ , capacity, . , ( shrink_to_fit).
, .
#include <cassert>
#include <string>
int main()
{
std::string s{"Exemplar"};
std::string::size_type const capacity = s.capacity();
s.clear();
assert(s.capacity() == capacity); // <-
assert(s.empty());
assert(s.size() == 0);
}
| (public -) |