GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::basic_string::empty - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. string
  3. basic_string
  4. empty

最終更新日時: 2026年08月25日 12時11分17秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<string>

std::basic_string::empty

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

概要

文字列が空か判定する。

戻り値

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

例外

投げない

例

#include <cassert>
#include <string>

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

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

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

出力

参照

  • P0600R1 [[nodiscard]] in the Library
    • C++20で[[nodiscard]]が付加された
  • P0980R1 Making std::string constexpr
    • C++20でconstexprが付加された
  • P2422R1 Remove nodiscard annotations from the standard library specification
    • C++26で[[nodiscard]]指定が削除された
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.