std::basic_string::empty(3)
πΈ NAME πΈ
okay so bestie, welcome to std::basic_string::empty(3) from the C++ Standard Libary manual β and yes, the header really spells it like that, iconic typo energy ππ
. This page is all about std::basic_string::empty, the bool-check for when your string has literally nothing to say.
β¨ Synopsis β¨
the signature is giving tiny but mighty:
bool empty() const; (noexcept since C++11)
(constexpr since C++20)
It checks if the string has no characters, i.e. whether begin() == end() β literally the empty-vibe check π.
π Parameters π
(none) β not a single parameter, bestie. Zero. Zilch. The audacity, honestly π.
π Return value π
true if the string is empty, false otherwise. bool energy only, no cap β¨.
π¦ Complexity π¦
Constant. Thatβs the whole complexity, periodt π¨.
π Example π
obsessed with a tiny demo, honestly:
// Run this code
#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:''
π See also π
the see-also squad is right here, bestie π«Ά:
sizeβ returns the number of characters (public member function)lengthβ (public member function)max_sizeβ returns the maximum number of characters (public member function)capacityβ returns the number of characters that can be held in currently allocated storage (public member function)sizeβ (C++17) returns the size of a container or array (function template)ssizeβ (C++17) (C++20) returns the size of a container or array (function template)emptyβ (C++17) checks whether the container is empty (function template)emptyβ checks whether the view is empty (public member function ofstd::basic_string_view<CharT,Traits>)
mwah πβ¨ β source/version: http://cppreference.com, date: 2024.06.10, page: std::basic_string::empty(3). thatβs the whole manual page, bestie, slay π¦π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms