• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <string_view>

    std::basic_string_view::empty

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

    概要

    文字列が空かどうかを判定する。

    戻り値

    return size() == 0;
    

    例外

    投げない

    #include <cassert>
    #include <string_view>
    
    int main()
    {
      std::string_view sv1;
      std::string_view sv2 = "Hello";
    
      assert(sv1.empty());
      assert(!sv2.empty());
    }
    

    出力

    バージョン

    言語

    • C++17

    処理系

    参照