最終更新日時(UTC):
が更新

履歴 編集

function
<string>

std::basic_string::empty

bool empty() const;                                  // C++03
bool empty() const noexcept;                         // C++11
[[nodiscard]] constexpr bool empty() const noexcept; // C++20

概要

文字列が空か判定する。

戻り値

size() == 0 の評価結果。

例外

投げない

#include <cassert>
#include <string>

int main()
{
  std::string s = "hello";
  assert(!s.empty());

  s.clear();
  assert(s.empty());

  s = "";
  assert(s.empty());
}

出力

参照