FreeBSD Manual Pages
std::basic_string::empty(3) C++ Standard Libary std::basic_string::empty(3) NAME std::basic_string::empty - std::basic_string::empty Synopsis bool empty() const; (until C++11) bool empty() const noexcept; (since C++11) (until C++20) [[nodiscard]] constexpr bool empty() const noexcept; (since C++20) Checks if the string has no characters, i.e. whether begin() == end(). Parameters (none) Return value true if the string is empty, false otherwise Complexity Constant. Example // 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 size returns the number of characters length (public member function) max_size returns the maximum number of characters (public member function) returns the number of characters that can be held in cur- rently allocated capacity storage (public member function) size ssize returns the size of a container or array (C++17) (function template) (C++20) empty checks whether the container is empty (C++17) (function template) empty checks whether the view is empty (C++17) (public member function of std::ba- sic_string_view<CharT,Traits>) http://cppreference.com 2022.07.31 std::basic_string::empty(3)
NAME | Synopsis | Parameters | Return value | Complexity | Example | Output: | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::string::empty&sektion=3&manpath=FreeBSD+Ports+15.0>
