Skip to content

Commit 1bb2328

Browse files
[libc++] Implement views::join_with (#65536)
* Implement "P2441R2 `views::join_with`" (https://wg21.link/P2441R2), closes #105185 * Implement LWG4074 (https://wg21.link/LWG4074), closes #105346 * Complete implementation of "P2711R1 Making multi-param constructors of views explicit" (https://wg21.link/P2711R1), closes #105252 * Complete implementation of "P2770R0 Stashing stashing iterators for proper flattening" (https://wg21.link/P2770R0), closes #105250
1 parent d6a486c commit 1bb2328

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+5843
-53
lines changed

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ Status
376376
---------------------------------------------------------- -----------------
377377
``__cpp_lib_ranges_iota`` ``202202L``
378378
---------------------------------------------------------- -----------------
379-
``__cpp_lib_ranges_join_with`` *unimplemented*
379+
``__cpp_lib_ranges_join_with`` ``202202L``
380380
---------------------------------------------------------- -----------------
381381
``__cpp_lib_ranges_repeat`` ``202207L``
382382
---------------------------------------------------------- -----------------

libcxx/docs/ReleaseNotes/21.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ Implemented Papers
4747
- P1222R4: A Standard ``flat_set`` (`Github <https://github.com/llvm/llvm-project/issues/105193>`__)
4848
- P2897R7: ``aligned_accessor``: An mdspan accessor expressing pointer over-alignment (`Github <https://github.com/llvm/llvm-project/issues/118372>`__)
4949
- P3247R2: Deprecate the notion of trivial types (`Github <https://github.com/llvm/llvm-project/issues/118387>`__)
50+
- P2441R2: ``views::join_with`` (`Github <https://github.com/llvm/llvm-project/issues/105185>`__)
51+
- P2711R1: Making multi-param constructors of ``views`` ``explicit`` (`Github <https://github.com/llvm/llvm-project/issues/105252>`__)
52+
- P2770R0: Stashing stashing ``iterators`` for proper flattening (`Github <https://github.com/llvm/llvm-project/issues/105250>`__)
5053

5154
Improvements and New Features
5255
-----------------------------

libcxx/docs/Status/Cxx23Papers.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"`P2273R3 <https://wg21.link/P2273R3>`__","Making ``std::unique_ptr`` constexpr","2022-02 (Virtual)","|Complete|","16",""
4848
"`P2387R3 <https://wg21.link/P2387R3>`__","Pipe support for user-defined range adaptors","2022-02 (Virtual)","|Complete|","19",""
4949
"`P2440R1 <https://wg21.link/P2440R1>`__","``ranges::iota``, ``ranges::shift_left`` and ``ranges::shift_right``","2022-02 (Virtual)","|Partial|","","Only ``ranges::iota`` is implemented."
50-
"`P2441R2 <https://wg21.link/P2441R2>`__","``views::join_with``","2022-02 (Virtual)","|In Progress|","",""
50+
"`P2441R2 <https://wg21.link/P2441R2>`__","``views::join_with``","2022-02 (Virtual)","|Complete|","21",""
5151
"`P2442R1 <https://wg21.link/P2442R1>`__","Windowing range adaptors: ``views::chunk`` and ``views::slide``","2022-02 (Virtual)","","",""
5252
"`P2443R1 <https://wg21.link/P2443R1>`__","``views::chunk_by``","2022-02 (Virtual)","|Complete|","18",""
5353
"","","","","",""
@@ -103,9 +103,9 @@
103103
"`P2708R1 <https://wg21.link/P2708R1>`__","No Further Fundamentals TSes","2022-11 (Kona)","|Nothing To Do|","",""
104104
"","","","","",""
105105
"`P0290R4 <https://wg21.link/P0290R4>`__","``apply()`` for ``synchronized_value<T>``","2023-02 (Issaquah)","","",""
106-
"`P2770R0 <https://wg21.link/P2770R0>`__","Stashing stashing ``iterators`` for proper flattening","2023-02 (Issaquah)","|Partial|","","``join_with_view`` hasn't been done yet since this type isn't implemented yet"
106+
"`P2770R0 <https://wg21.link/P2770R0>`__","Stashing stashing ``iterators`` for proper flattening","2023-02 (Issaquah)","|Complete|","21",""
107107
"`P2164R9 <https://wg21.link/P2164R9>`__","``views::enumerate``","2023-02 (Issaquah)","","",""
108-
"`P2711R1 <https://wg21.link/P2711R1>`__","Making multi-param constructors of ``views`` ``explicit``","2023-02 (Issaquah)","|In Progress|","","``join_with_view`` hasn't been done yet since this type isn't implemented yet"
108+
"`P2711R1 <https://wg21.link/P2711R1>`__","Making multi-param constructors of ``views`` ``explicit``","2023-02 (Issaquah)","|Complete|","21",""
109109
"`P2609R3 <https://wg21.link/P2609R3>`__","Relaxing Ranges Just A Smidge","2023-02 (Issaquah)","|Complete|","20","Implemented as a DR in C++20. Other implementations will do the same."
110110
"`P2713R1 <https://wg21.link/P2713R1>`__","Escaping improvements in ``std::format``","2023-02 (Issaquah)","|Complete|","19",""
111111
"`P2675R1 <https://wg21.link/P2675R1>`__","``format``'s width estimation is too approximate and not forward compatible","2023-02 (Issaquah)","|Complete|","17",""

libcxx/docs/Status/Cxx2cIssues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"`LWG4060 <https://wg21.link/LWG4060>`__","``submdspan`` preconditions do not forbid creating invalid pointer","2024-06 (St. Louis)","","",""
6767
"`LWG4061 <https://wg21.link/LWG4061>`__","Should ``std::basic_format_context`` be default-constructible/copyable/movable?","2024-06 (St. Louis)","|Complete|","19",""
6868
"`LWG4071 <https://wg21.link/LWG4071>`__","``reference_wrapper`` comparisons are not SFINAE-friendly","2024-06 (St. Louis)","|Complete|","19",""
69-
"`LWG4074 <https://wg21.link/LWG4074>`__","``compatible-joinable-ranges`` is underconstrained","2024-06 (St. Louis)","","",""
69+
"`LWG4074 <https://wg21.link/LWG4074>`__","``compatible-joinable-ranges`` is underconstrained","2024-06 (St. Louis)","|Complete|","21",""
7070
"`LWG4076 <https://wg21.link/LWG4076>`__","``concat_view`` should be freestanding","2024-06 (St. Louis)","","",""
7171
"`LWG4079 <https://wg21.link/LWG4079>`__","Missing Preconditions in ``concat_view::iterator``\`s conversion constructor","2024-06 (St. Louis)","","",""
7272
"`LWG4082 <https://wg21.link/LWG4082>`__","``views::concat(r)`` is well-formed when ``r`` is an ``output_range``","2024-06 (St. Louis)","","",""

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ set(files
706706
__ranges/iota_view.h
707707
__ranges/istream_view.h
708708
__ranges/join_view.h
709+
__ranges/join_with_view.h
709710
__ranges/lazy_split_view.h
710711
__ranges/movable_box.h
711712
__ranges/non_propagating_cache.h

libcxx/include/__ranges/concepts.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#ifndef _LIBCPP___RANGES_CONCEPTS_H
1111
#define _LIBCPP___RANGES_CONCEPTS_H
1212

13+
#include <__concepts/common_reference_with.h>
1314
#include <__concepts/constructible.h>
15+
#include <__concepts/convertible_to.h>
1416
#include <__concepts/movable.h>
1517
#include <__concepts/same_as.h>
1618
#include <__config>
@@ -25,6 +27,8 @@
2527
#include <__ranges/enable_view.h>
2628
#include <__ranges/size.h>
2729
#include <__type_traits/add_pointer.h>
30+
#include <__type_traits/common_reference.h>
31+
#include <__type_traits/common_type.h>
2832
#include <__type_traits/is_reference.h>
2933
#include <__type_traits/remove_cvref.h>
3034
#include <__type_traits/remove_reference.h>
@@ -133,6 +137,42 @@ concept viewable_range =
133137
(is_lvalue_reference_v<_Tp> ||
134138
(movable<remove_reference_t<_Tp>> && !__is_std_initializer_list<remove_cvref_t<_Tp>>))));
135139

140+
# if _LIBCPP_STD_VER >= 23
141+
142+
template <class... _Rs>
143+
using __concat_reference_t _LIBCPP_NODEBUG = common_reference_t<range_reference_t<_Rs>...>;
144+
145+
template <class... _Rs>
146+
using __concat_value_t _LIBCPP_NODEBUG = common_type_t<range_value_t<_Rs>...>;
147+
148+
template <class... _Rs>
149+
using __concat_rvalue_reference_t _LIBCPP_NODEBUG = common_reference_t<range_rvalue_reference_t<_Rs>...>;
150+
151+
template <class _Ref, class _RRef, class _It>
152+
concept __concat_indirectly_readable_impl = requires(const _It __it) {
153+
{ *__it } -> convertible_to<_Ref>;
154+
{ ranges::iter_move(__it) } -> convertible_to<_RRef>;
155+
};
156+
157+
template <class... _Rs>
158+
concept __concat_indirectly_readable =
159+
common_reference_with<__concat_reference_t<_Rs...>&&, __concat_value_t<_Rs...>&> &&
160+
common_reference_with<__concat_reference_t<_Rs...>&&, __concat_rvalue_reference_t<_Rs...>&&> &&
161+
common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, const __concat_value_t<_Rs...>&> &&
162+
(__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
163+
__concat_rvalue_reference_t<_Rs...>,
164+
iterator_t<_Rs>> &&
165+
...);
166+
167+
template <class... _Rs>
168+
concept __concatable = requires {
169+
typename __concat_reference_t<_Rs...>;
170+
typename __concat_value_t<_Rs...>;
171+
typename __concat_rvalue_reference_t<_Rs...>;
172+
} && __concat_indirectly_readable<_Rs...>;
173+
174+
# endif // _LIBCPP_STD_VER >= 23
175+
136176
} // namespace ranges
137177

138178
#endif // _LIBCPP_STD_VER >= 20

0 commit comments

Comments
 (0)