std::array::size(3)
π NAME π
Okay so welcome to std::array::size(3), bestie β it's from the C++ Standard Libary manual, and the NAME section is literally std::array::size - std::array::size (yes, it said it twice, and honestly? iconic). β¨
β¨ Synopsis β¨
This is the vibe:
constexpr size_type size() const noexcept;
It's been around since C++11, and it returns the number of elements in the container, i.e. std::distance(begin(), end()). No cap. π
π Parameters π
(none) β literally zero parameters, not a single one, the param list is empty and thriving. π«Ά
πΈ Return value πΈ
The number of elements in the container. That's it, that's the tea. π
π Complexity π
Constant. β
π¦ Example π¦
The following code uses size to display the number of elements in a std::array:
// Run this code
#include <array>
#include <iostream>
int main()
{
std::array<int, 4> 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)sizessizeβ returns the size of a container or array (C++17) (function template) (C++20)
mwah π this page came from http://cppreference.com, version/date 2024.06.10 β see u next time bestie π«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms