[libcxx-commits] [PATCH] D141699: [libc++][ranges] Implement P2474R2(`views::repeat`).

Yurong via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 5 03:36:18 PST 2023


yronglin added inline comments.


================
Comment at: libcxx/include/__ranges/repeat_view.h:110
+      piecewise_construct_t, tuple<_TpArgs...> __value_args, tuple<_BoundArgs...> __bound_args = tuple<>{})
+      : __value_(std::in_place, std::ranges::__repeat_view_make_from_tuple<_Tp>(std::move(__value_args))),
+        __bound_(std::ranges::__repeat_view_make_from_tuple<_Bound>(std::move(__bound_args))) {}
----------------
philnik wrote:
> I think we should instead add new constructors to `__copyable_box`, so we can construct the type in-place. For example (not tested):
> ```lang=c++
>     template <class... _Args, size_t... _Indices>
>       requires is_constructible_v<_Tp, _Args...>
>     _LIBCPP_HIDE_FROM_ABI constexpr explicit __copyable_box(
>         piecewise_construct_t, tuple<_Args...> __tuple, index_sequence<_Indices...>)
>         : __copyable_box(in_place, std::get<_Indices>(std::forward<tuple<_Args...>>(__tuple))...) {}
> 
>     template <class... _Args>
>       requires is_constructible_v<_Tp, _Args...>
>     _LIBCPP_HIDE_FROM_ABI constexpr explicit __copyable_box(piecewise_construct_t, tuple<_Args...> __args)
>         : __copyable_box(std::move(__args), std::make_index_sequence<sizeof...(_Args)>()) {}
> ```
> 
> Then we can simply do `__value_(piecewise_construct, std::move(__value_args))`.
I have tried to add new ctor to __copyable_box, but is_constructible_v<_Tp, _Args...> still need a workaround, so, can we add this new ctor and remove `__repeat_view_constructible_from` in LLVM 18? WDYH?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141699/new/

https://reviews.llvm.org/D141699



More information about the libcxx-commits mailing list