Skip to content

Commit 9748a32

Browse files
committed
[libc++] implement 'std::generator'
1 parent 652f44f commit 9748a32

File tree

7 files changed

+24
-14
lines changed

7 files changed

+24
-14
lines changed

libcxx/include/__std_clang_module

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
#if !defined(_LIBCPP_HAS_NO_THREADS)
105105
# include <future>
106106
#endif
107+
#include <generator>
107108
#include <initializer_list>
108109
#include <inttypes.h>
109110
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)

libcxx/include/generator

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
#define _LIBCPP_GENERATOR
1212

1313
#include <__assert>
14+
#include <__concepts/common_reference_with.h>
1415
#include <__concepts/constructible.h>
1516
#include <__concepts/convertible_to.h>
17+
#include <__concepts/same_as.h>
1618
#include <__config>
1719
#include <__coroutine/coroutine_handle.h>
1820
#include <__coroutine/coroutine_traits.h>
@@ -23,6 +25,7 @@
2325
#include <__memory/addressof.h>
2426
#include <__memory/allocator_arg_t.h>
2527
#include <__memory/allocator_traits.h>
28+
#include <__ranges/access.h>
2629
#include <__ranges/concepts.h>
2730
#include <__ranges/elements_of.h>
2831
#include <__ranges/view_interface.h>
@@ -34,9 +37,18 @@
3437
#include <__type_traits/is_reference.h>
3538
#include <__type_traits/is_void.h>
3639
#include <__type_traits/remove_cvref.h>
40+
#include <__type_traits/remove_reference.h>
3741
#include <__utility/exchange.h>
42+
#include <__utility/move.h>
3843
#include <__utility/swap.h>
3944

45+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
46+
# pragma GCC system_header
47+
#endif
48+
49+
_LIBCPP_PUSH_MACROS
50+
#include <__undef_macros>
51+
4052
#if _LIBCPP_STD_VER >= 23
4153

4254
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -86,7 +98,7 @@ private:
8698
__root_data __root;
8799
__recursive_data __recursive;
88100

89-
~__union() noexcept {}
101+
_LIBCPP_HIDE_FROM_ABI ~__union() noexcept {}
90102
} __data_;
91103

92104
// The `__tag_` stores the active member of the `__data_` union:
@@ -370,10 +382,8 @@ private:
370382

371383
_LIBCPP_END_NAMESPACE_STD
372384

373-
#endif
385+
#endif // _LIBCPP_STD_VER >= 23
374386

375-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
376-
# pragma GCC system_header
377-
#endif
387+
_LIBCPP_POP_MACROS
378388

379-
#endif
389+
#endif // _LIBCPP_GENERATOR

libcxx/include/module.modulemap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ module std_future [system] {
9999
header "future"
100100
export *
101101
}
102+
module std_generator [system] {
103+
header "generator"
104+
export *
105+
}
102106
module std_initializer_list [system] {
103107
header "initializer_list"
104108
export *

libcxx/modules/std.compat.cppm.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ module;
6363
# if __has_include(<flat_set>)
6464
# error "please update the header information for <flat_set> in headers_not_available in utils/libcxx/header_information.py"
6565
# endif // __has_include(<flat_set>)
66-
# if __has_include(<generator>)
67-
# error "please update the header information for <generator> in headers_not_available in utils/libcxx/header_information.py"
68-
# endif // __has_include(<generator>)
6966
# if __has_include(<hazard_pointer>)
7067
# error "please update the header information for <hazard_pointer> in headers_not_available in utils/libcxx/header_information.py"
7168
# endif // __has_include(<hazard_pointer>)

libcxx/modules/std.cppm.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ module;
7979
#if !defined(_LIBCPP_HAS_NO_THREADS)
8080
# include <future>
8181
#endif
82+
#include <generator>
8283
#include <initializer_list>
8384
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
8485
# include <iomanip>
@@ -185,9 +186,6 @@ module;
185186
# if __has_include(<flat_set>)
186187
# error "please update the header information for <flat_set> in headers_not_available in utils/libcxx/header_information.py"
187188
# endif // __has_include(<flat_set>)
188-
# if __has_include(<generator>)
189-
# error "please update the header information for <generator> in headers_not_available in utils/libcxx/header_information.py"
190-
# endif // __has_include(<generator>)
191189
# if __has_include(<hazard_pointer>)
192190
# error "please update the header information for <hazard_pointer> in headers_not_available in utils/libcxx/header_information.py"
193191
# endif // __has_include(<hazard_pointer>)

libcxx/modules/std/generator.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
//===----------------------------------------------------------------------===//
99

1010
export namespace std {
11-
#if 0
11+
#if _LIBCPP_STD_VER >= 23
12+
// [coro.generator], class template generator
1213
using std::generator;
1314
#endif
1415
} // namespace std

libcxx/utils/libcxx/header_information.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@
141141
"debugging",
142142
"flat_map",
143143
"flat_set",
144-
"generator",
145144
"hazard_pointer",
146145
"linalg",
147146
"rcu",

0 commit comments

Comments
 (0)