std::basic_string<CharT,Traits,Allocator>:: empty
From cppreference.net
<
cpp
|
string
|
basic string
C++
Strings library
| Classes | ||||
|
(C++17)
|
||||
std::basic_string
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
bool
empty
(
)
const
;
|
(C++11부터 noexcept)
(C++20부터 constexpr) |
|
문자열에 문자가 없는지 확인합니다. 즉, 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:''
참고 항목
|
문자 수를 반환합니다
(public member function) |
|
|
최대 문자 수를 반환합니다
(public member function) |
|
|
현재 할당된 저장 공간에 보관할 수 있는 문자 수를 반환합니다
(public member function) |
|
|
(C++17)
(C++20)
|
컨테이너나 배열의 크기를 반환합니다
(function template) |
|
(C++17)
|
컨테이너가 비어 있는지 확인합니다
(function template) |
|
뷰가 비어 있는지 확인합니다
(public member function of
std::basic_string_view<CharT,Traits>
)
|