A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../experimental/../string/basic_string/empty.html below:

std::basic_string<CharT,Traits,Allocator>::empty - cppreference.com

bool empty() const;

(noexcept since C++11)
(constexpr since C++20)

Checks if the string has no characters, i.e. whether begin() == end().

[edit] Parameters

(none)

[edit] Return value

true if the string is empty, false otherwise

[edit] Complexity

Constant.

[edit] Example
#include <iostream>
#include <string>
 
int main()
{
    std::string s;
    std::boolalpha(std::cout);
    std::cout << "s.empty():" << s.empty() << "\t s:'" << s << "'\n";
 
    s = "Exemplar";
    std::cout << "s.empty():" << s.empty() << "\t s:'" << s << "'\n";
 
    s = "";
    std::cout << "s.empty():" << s.empty() << "\t s:'" << s << "'\n";
}

Output:

s.empty():true   s:''
s.empty():false  s:'Exemplar'
s.empty():true   s:''
[edit] See also returns the number of characters
(public member function) [edit] returns the maximum number of characters
(public member function) [edit] returns the number of characters that can be held in currently allocated storage
(public member function) [edit] returns the size of a container or array
(function template) [edit] checks whether the container is empty
(function template) [edit] checks whether the view is empty
(public member function of std::basic_string_view<CharT,Traits>) [edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4