26
Ranges library
[ranges]
26.7
Range adaptors
[range.adaptors]
26.7.19
Counted view
[range.counted]
1
#
A counted view presents a view of the elements of the counted range (
[iterator.
requirements.
general]
)
i
+
[
0
,
n
)
for an iterator
i
and non-negative integer
n
.
2
#
The name
views
::
counted
denotes a customization point object (
[customization.
point.
object]
)
.
Let
E
and
F
be expressions, let
T
be
decay_
t
<
decltype
(
(
E
)
)
>
, and let
D
be
iter_
difference_
t
<
T
>
.
If
decltype
(
(
F
)
)
does not model
convertible_
to
<
D
>
,
views
::
counted
(
E, F
)
is ill-formed
.
[
Note
1
:
This case can result in substitution failure when
views
::
counted
(
E, F
)
appears in the immediate context of a template instantiation
.
—
end note
]
Otherwise,
views
::
counted
(
E, F
)
is expression-equivalent to:
(2.1)
If
T
models
contiguous_
iterator
, then
span
(
to_
address
(
E
)
,
static_
cast
<
size_
t
>
(
static_
cast
<
D
>
(
F
)
)
)
.
(2.2)
Otherwise, if
T
models
random_
access_
iterator
, then
subrange
(
E, E
+
static_
cast
<
D
>
(
F
)
)
, except that
E
is evaluated only once
.
(2.3)
Otherwise,
subrange
(
counted_
iterator
(
E, F
)
, default_
sentinel
)
.