| ||||||||||||||||||||||
| Range primitives | |||||||
| |||||||
| Range concepts | |||||||||||||||||||
| |||||||||||||||||||
| Range factories | |||||||||
| |||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helper items | |||||||||||||||||
| |||||||||||||||||
| Member functions | ||||
adjacent_view::size | ||||
(C++26) | ||||
| Iterator | ||||
| Member functions | ||||
| Non-member functions | ||||
| Sentinel | ||||
| Member functions | ||||
| Non-member functions | ||||
constexprauto size() requiresranges::sized_range<V>; | (since C++23) | |
constexprauto size()const requiresranges::sized_range<const V>; | (since C++23) | |
Returns the number of elements.
Letbase_ be the underlying view. Equivalent to:
using SizeType= decltype(ranges::size(base_));using CommonType=ranges::common_type_t<SizeType,std::size_t>;auto size=static_cast<CommonType>(ranges::size(base_));size-=std::min<CommonType>(size, N-1);returnstatic_cast<SizeType>(size);
Contents |
(none)
The number of elements, may be0 ifranges::size(base_) is less thanN.
#include <ranges> int main(){constexprstaticauto v={1,2,3,4,5,6}; constexprint width1{4};constexprauto view1{std::views::adjacent<width1>(v)}; static_assert(view1.size()==3); static_assert(view1.size()==(v.size()- width1+1)); constexprint width2{8};constexprauto view2{std::views::adjacent<width2>(v)};// window is too wide, so view2 has no elements: static_assert(view2.size()==0);}
(C++20) | returns an integer equal to the size of a range (customization point object)[edit] |
(C++20) | returns a signed integer equal to the size of a range (customization point object)[edit] |