[range.prim.size] # 25 Ranges library [[ranges]](./#ranges) ## 25.3 Range access [[range.access]](range.access#range.prim.size) ### 25.3.10 ranges​::​size [range.prim.size] [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1024) The name ranges​::​size denotes a customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))[.](#1.sentence-1) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1028) Given a subexpression E with type T, let t be an lvalue that denotes the reified object for E[.](#2.sentence-1) Then: - [(2.1)](#2.1) If T is an array of unknown bound ([[dcl.array]](dcl.array#term.array.type "9.3.4.5 Arrays")), ranges​::​size(E) is ill-formed[.](#2.1.sentence-1) - [(2.2)](#2.2) Otherwise, if T is an array type, ranges​::​size(E) is expression-equivalent to auto(extent_v)[.](#2.2.sentence-1) - [(2.3)](#2.3) Otherwise, if disable_sized_range> ([[range.sized]](range.sized "25.4.4 Sized ranges")) is false and auto(t.size()) is a valid expression of integer-like type ([[iterator.concept.winc]](iterator.concept.winc "24.3.4.4 Concept weakly_­incrementable")), ranges​::​size(E) is expression-equivalent to auto(​t.size())[.](#2.3.sentence-1) - [(2.4)](#2.4) Otherwise, if T is a class or enumeration type, disable_sized_range> is false and auto(size(t)) is a valid expression of integer-like type where the meaning of size is established as-if by performing argument-dependent lookup only ([[basic.lookup.argdep]](basic.lookup.argdep "6.5.4 Argument-dependent name lookup")), then ranges​::​size(E) is expression-equivalent to that expression[.](#2.4.sentence-1) - [(2.5)](#2.5) Otherwise, if *to-unsigned-like*(ranges​::​end(t) - ranges​::​begin(t)) ([[ranges.syn]](ranges.syn "25.2 Header synopsis")) is a valid expression and the types I and S of ranges​::​begin(t) and ranges​::​end(t) (respectively) model both [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]") ([[iterator.concept.sizedsentinel]](iterator.concept.sizedsentinel "24.3.4.8 Concept sized_­sentinel_­for")) and [forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11 Concept forward_­iterator [iterator.concept.forward]"), then ranges​::​size(E) is expression-equivalent to *to-unsigned-like*(ranges​::​end(t) - ranges​::​begin(t))[.](#2.5.sentence-1) - [(2.6)](#2.6) Otherwise, ranges​::​size(E) is ill-formed[.](#2.6.sentence-1) [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1075) [*Note [1](#note-1)*: Diagnosable ill-formed cases above result in substitution failure when ranges​::​size(E) appears in the immediate context of a template instantiation[.](#3.sentence-1) — *end note*] [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1082) [*Note [2](#note-2)*: Whenever ranges​::​size(E) is a valid expression, its type is integer-like[.](#4.sentence-1) — *end note*]