std::deque::size(3)

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

πŸ’… std::deque::size(3) β€” from the C++ Standard Libary manual πŸ’…

okay bestie, this page is from the C++ Standard Libary manual (yes, that’s how it’s spelled here), and it’s all about std::deque::size. it’s a tiny icon, it’s useful, and it absolutely ate. no cap. πŸ’–

🌸 NAME 🌸

std::deque::size β€” std::deque::size 🫢

πŸŽ€ Synopsis πŸŽ€

size_type size() const;  (noexcept since C++11)

Returns the number of elements in the container, i.e. std::distance(begin(), end()). literally just β€œhow many things are in here?” energy. ✨

πŸ¦‹ Parameters πŸ¦‹

(none) β€” nothing to pass in, bestie. it’s giving low-maintenance. πŸ’…

🌈 Return value 🌈

The number of elements in the container. that’s it, that’s the tea. πŸ“

⭐ Complexity ⭐

Constant. periodt. πŸ”₯

πŸ’œ Example πŸ’œ

The following code uses size to display the number of elements in a std::deque:

// Run this code

#include <deque>
#include <iostream>

int main()
{
    std::deque<int> nums{1, 3, 5, 7};

    std::cout << "nums contains " << nums.size() << " elements.\n";
}

πŸŽ€ Output πŸŽ€

nums contains 4 elements.

πŸ‘‘ See also πŸ‘‘

  • empty β€” checks whether the container is empty (public member function)
  • max_size β€” returns the maximum possible number of elements (public member function)
  • resize β€” changes the number of elements stored (public member function)
  • size
  • ssize β€” returns the size of a container or array
  • (C++17) β€” (function template)
  • (C++20)

source: http://cppreference.com, version/date: 2024.06.10, page: std::deque::size(3) β€” mwah, bestie πŸ’‹πŸ’–

πŸ“¦ where this page comes from