Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::array<T,N>::empty

      From cppreference.com
      <cpp‎ |container‎ |array

      [edit template]
       
       
       
       
      constexprbool empty()constnoexcept;
      (since C++11)

      Checks if the container has no elements.

      Contents

      [edit]Return value

      true if the container is empty,false otherwise.

      [edit]Complexity

      Constant.

      [edit]Example

      [edit]

      The following code usesempty to check if astd::array contains any elements:

      Run this code
      #include <array>#include <iostream> int main(){std::array<int,4> numbers{3,1,4,1};std::array<int,0> no_numbers; std::cout<<std::boolalpha;std::cout<<"numbers.empty(): "<< numbers.empty()<<'\n';std::cout<<"no_numbers.empty(): "<< no_numbers.empty()<<'\n';}

      Output:

      numbers.empty(): falseno_numbers.empty(): true

      [edit]See also

      returns the number of elements
      (public member function)[edit]
      (C++17)
      checks whether the container is empty
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/container/array/empty&oldid=119360"

      [8]ページ先頭

      ©2009-2025 Movatter.jp