[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/container/vector/empty [Back]  [Original]

std::vector::empty cppreference.com
cppreference.com

std::vector::empty

cppreference.com
<tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody>
bool empty() const;
( C++11)
bool empty() const noexcept;
( C++11)
( C++20)
[[nodiscard]] constexpr bool empty() const noexcept;
( C++20)

, .. , begin() == end().

()

true , false .

.

#include <vector>
#include <iostream>
 
int main()
{
    std::cout << std::boolalpha;
    std::vector<int> numbers;
    std::cout << " , numbers.empty(): " << numbers.empty() << '\n';

    numbers.push_back(42);
    std::cout << "  , numbers.empty(): " << numbers.empty() << '\n';
}

:

 , numbers.empty(): true
  , numbers.empty(): false

See also


(public -) []

Web Proxy Viewer  |  New URL  |  Original Page