std::vector::empty(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– std::vector::empty(3) πŸ’–

okay so bestie, this page is from the C++ Standard Libary manual β€” yes, that's the manual name, typo and all, and we are not fixing it πŸ’…. It's the std::vector::empty(3) page, and it's literally about checking if a vector has no elements.

🌸 NAME 🌸

std::vector::empty β€” std::vector::empty

it's giving "same name, same energy," and honestly that's iconic. no cap.

✨ Synopsis ✨

here's the signature, bestie β€” keep the const, the noexcept, and the constexpr exactly where they are:

          bool empty() const;  (noexcept since C++11)
                               (constexpr since C++20)

so it checks if the container has no elements, i.e. whether begin() == end(). that's the whole vibe check πŸ”₯.

πŸŽ€ Parameters πŸŽ€

(none) β€” literally none, bestie. not a single parameter in sight πŸ™ˆ.

πŸ¦‹ Return value πŸ¦‹

true if the container is empty, false otherwise. periodt. πŸ’–

⭐ Complexity ⭐

Constant. that's the whole note. iconic.

🌈 Example 🌈

       // Run this code

        #include <vector>
        #include <iostream>

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

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

πŸ“ Output: πŸ“

        Initially, numbers.empty(): true
        After adding elements, numbers.empty(): false

πŸ‘€ See also πŸ‘€

  • size β€” returns the number of elements (public member function)
  • empty β€” checks whether the container is empty (C++17) (function template)

that's the whole page, bestie 🫢 β€” source: http://cppreference.com, date: 2024.06.10, and the page is std::vector::empty(3). mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from