24
Ranges library
[ranges]
24.7
Range adaptors
[range.adaptors]
24.7.4
All view
[range.all]
24.7.4.1
General
[range.all.general]
1
#
views
::
all
returns a
view
that includes all elements of its
range
argument
.
2
#
The name
views
::
all
denotes a range adaptor object (
[range.
adaptor.
object]
)
.
Given a subexpression
E
, the expression
views
::
all
(
E
)
is expression-equivalent to:
(2.1)
decay-copy
(
E
)
if the decayed type of
E
models
view
.
(2.2)
Otherwise,
ref_view
{
E
}
if that expression is well-formed
.
(2.3)
Otherwise,
subrange
{
E
}
.
24.7.4.2
Class template
ref_view
[range.ref.view]
1
#
ref_view
is a
view
of the elements of some other
range
.
namespace
std
::
ranges
{
template
<
range
R
>
requires
is_object_v
<
R
>
class
ref_view
:
public
view_interface
<
ref_view
<
R
>
>
{
private
:
R
*
r_
=
nullptr
;
//
exposition only
public
:
constexpr
ref_view
(
)
noexcept
=
default
;
template
<
not-same-as
<
ref_view
>
T
>
requires
see below
constexpr
ref_view
(
T
&
&
t
)
;
constexpr
R
&
base
(
)
const
{
return
*
r_
;
}
constexpr
iterator_t
<
R
>
begin
(
)
const
{
return
ranges
::
begin
(
*
r_
)
;
}
constexpr
sentinel_t
<
R
>
end
(
)
const
{
return
ranges
::
end
(
*
r_
)
;
}
constexpr
bool
empty
(
)
const
requires
requires
{
ranges
::
empty
(
*
r_
)
;
}
{
return
ranges
::
empty
(
*
r_
)
;
}
constexpr
auto
size
(
)
const
requires
sized_range
<
R
>
{
return
ranges
::
size
(
*
r_
)
;
}
constexpr
auto
data
(
)
const
requires
contiguous_range
<
R
>
{
return
ranges
::
data
(
*
r_
)
;
}
}
;
template
<
class
R
>
ref_view
(
R
&
)
-
>
ref_view
<
R
>
;
}
🔗
template
<
not-same-as
<
ref_view
>
T
>
requires
see below
constexpr
ref_view
(
T
&
&
t
)
;
2
#
Effects
: Initializes
r_
with
addressof
(
static_cast
<
R
&
>
(
std
::
forward
<
T
>
(
t
)
)
)
.
3
#
Remarks
: Let
FUN
denote the exposition-only functions
void
FUN
(
R
&
)
;
void
FUN
(
R
&
&
)
=
delete
;
The expression in the
requires-clause
is equivalent to:
convertible_to
<
T, R
&
>
&
&
requires
{
FUN
(
declval
<
T
>
(
)
)
;
}