26
Ranges library
[ranges]
26.8
Range generators
[coro.generator]
26.8.3
Class template
generator
[coro.generator.class]
namespace
std
{
template
<
class
Ref,
class
V
=
void
,
class
Allocator
=
void
>
class
generator
:
public
ranges
::
view_interface
<
generator
<
Ref, V, Allocator
>
>
{
private
:
using
value
=
conditional_t
<
is_void_v
<
V
>
, remove_cvref_t
<
Ref
>
, V
>
;
//
exposition only
using
reference
=
conditional_t
<
is_void_v
<
V
>
, Ref
&
&
, Ref
>
;
//
exposition only
//
[coro.
generator.
iterator]
, class
generator::
iterator
class
iterator
;
//
exposition only
public
:
using
yielded
=
conditional_t
<
is_reference_v
<
reference
>
,
reference
,
const
reference
&
>
;
//
[coro.
generator.
promise]
, class
generator::promise_
type
class
promise_type; generator
(
const
generator
&
)
=
delete
; generator
(
generator
&
&
other
)
noexcept
;
~
generator
(
)
; generator
&
operator
=
(
generator other
)
noexcept
;
iterator
begin
(
)
; default_sentinel_t end
(
)
const
noexcept
;
private
:
coroutine_handle
<
promise_type
>
coroutine_
=
nullptr
;
//
exposition only
unique_ptr
<
stack
<
coroutine_handle
<
>
>
>
active_
;
//
exposition only
}
;
}
1
#
Mandates
:
(1.1)
If
Allocator
is not
void
,
allocator_
traits
<
Allocator
>
::
pointer
is a pointer type
.
(1.2)
value
is a cv-unqualified object type
.
(1.3)
reference
is either a reference type, or a cv-unqualified object type that models
copy_
constructible
.
(1.4)
Let
RRef
denote
remove_
reference_
t
<
reference
>
&
&
if
reference
is a reference type, and
reference
otherwise
.
Each of:
(1.4.1)
common_
reference_
with
<
reference
&
&
,
value
&
>
,
(1.4.2)
common_
reference_
with
<
reference
&
&
, RRef
&
&
>
, and
(1.4.3)
common_
reference_
with
<
RRef
&
&
,
const
value
&
>
is modeled
.
[
Note
1
:
These requirements ensure the exposition-only
iterator
type can model
indirectly_
readable
and thus
input_
iterator
.
—
end note
]
2
#
If
Allocator
is not
void
, it shall meet the
Cpp17Allocator
requirements
.
3
#
Specializations of
generator
model
view
and
input_
range
.
4
#
The behavior of a program that adds a specialization for
generator
is undefined
.