[ Web Proxy ]
URL:
Viewing: http://ja.cppreference.com/cpp/string/basic_string/empty [Back]  [Original]

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

std::basic_string<CharT,Traits,Allocator>::empty

: cppreference.com
 
C++
(C++20)
(C++20)
(C++17)
(C++11)
(C++11)
(C++11)
 
 
std::basic_string
 
<tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody>
bool empty() const;
(C++11)
bool empty() const noexcept;
(C++11)
(C++20)
[[nodiscard]] constexpr bool empty() const noexcept;
(C++20)

begin() == end()

()

true false

#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";
}

:

s.empty():true	 s:''
s.empty():false	 s:'Exemplar'
s.empty():true	 s:''


() [edit]

Web Proxy Viewer  |  New URL  |  Original Page