24
Ranges library
[ranges]
24.7
Range adaptors
[range.adaptors]
24.7.12
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
:
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
<
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
}
.