[libcxx-commits] [libcxx] [libc++][ranges] LWG3984: `ranges::to`'s recursion branch may be ill-formed (PR #87964)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 10 20:15:36 PDT 2024


================
@@ -129,7 +130,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Container to(_Range&& __r
     // Try the recursive case.
   } else if constexpr (input_range<range_reference_t<_Range>>) {
     return ranges::to<_Container>(
-        __range | views::transform([](auto&& __elem) {
+        ranges::ref_view(__range) | views::transform([](auto&& __elem) {
----------------
frederick-vs-ja wrote:

We're already in the `ranges` namespace, and `ranges::ref_view` is not a function (or function template).
```suggestion
        ref_view(__range) | views::transform([](auto&& __elem) {
```

https://github.com/llvm/llvm-project/pull/87964


More information about the libcxx-commits mailing list