#include#include #include int main() { std::vector v = {1, 2, 3, 4, 5}; std::cout << "Size of vector is: " << std::ranges::size(v) << std::endl; return 0; }
#includeThis code uses std::ranges::size to determine the size of a sub-range of a vector. The sub-range is created using std::views::drop and std::views::take. The package/library used is the C++20 standard library#include #include int main() { std::vector v = {1, 2, 3, 4, 5}; auto sub_range = v | std::views::drop(2) | std::views::take(2); std::cout << "Size of sub-range is: " << std::ranges::size(sub_range) << std::endl; return 0; }