Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/string/basic string/clear"

From cppreference.com
< cpp‎ | string‎ | basic string
(use rev to mark the changes between standards)
(don't use ddcl)
Line 1: Line 1:
 
{{cpp/string/basic_string/title | clear}}
 
{{cpp/string/basic_string/title | clear}}
 
{{cpp/string/basic_string/navbar}}
 
{{cpp/string/basic_string/navbar}}
{{ddcl |  
+
{{dcl begin}}
 +
{{dcl |  
 
void clear();
 
void clear();
 
}}
 
}}
 +
{{dcl end}}
  
 
Removes all characters from the string. The allocated memory will not be released, effectively leaving the {{lc|capacity}} of the string unchanged. The past-the-end iterators are not invalidated.  
 
Removes all characters from the string. The allocated memory will not be released, effectively leaving the {{lc|capacity}} of the string unchanged. The past-the-end iterators are not invalidated.  

Revision as of 03:54, 25 June 2013

 
 
 
std::basic_string
Member functions
Element access
Iterators
Capacity
Modifiers
basic_string::clear
Search
Operations
Constants
Non-member functions
I/O
Comparison
(until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20)
Numeric conversions
(C++11)(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
Literals
Helper classes
Deduction guides (C++17)

 
void clear();

Removes all characters from the string. The allocated memory will not be released, effectively leaving the capacity of the string unchanged. The past-the-end iterators are not invalidated.

Contents

Parameters

(none)

Return value

(none)

Exceptions

(none) (until C++11)
noexcept specification:  
noexcept
  
(since C++11)

Complexity

Linear in the size of the string.

See also

removes characters
(public member function) [edit]