C++ common Array size is a preprocessor macro that returns the number of elements in a statically allocated array. It is defined in the header file of the standard library.
Example code:
#include
int main() { int arr[5] = {1, 2, 3, 4, 5}; constexpr int arrSize = std::size(arr);
// Use arrSize in your code as needed // ... }
In this example, arrSize will be equal to 5, which is the size of the arr array.
Another example:
#include
struct Point { int x; int y; };
int main() { std::array points = {{{0, 0}, {10, 10}, {20, 20}}}; constexpr int numPoints = std::size(points);
// Use numPoints in your code as needed // ... }
In this example, numPoints will be equal to 3, which is the number of elements in the points array.
The package library used in these examples is the standard library, which provides the header file.
C++ (Cpp) Array::size - 30 examples found. These are the top rated real world C++ (Cpp) examples of common::Array::size extracted from open source projects. You can rate examples to help us improve the quality of examples.