[libcxx-commits] [libcxx] WIP [libc++][ranges] P3138R3: `views::cache_latest` (PR #151450)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 4 03:18:26 PDT 2026


================
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++26
+
+// <ranges>
+
+// class cache_latest_view
+
+//   template<class R>
+//     cache_latest_view(R&&) -> cache_latest_view<views::all_t<R>>;
+
+#include <concepts>
+#include <ranges>
+#include <utility>
+#include <vector>
+
+static_assert(std::same_as<decltype(std::ranges::cache_latest_view(std::vector<int>{})),
+                           std::ranges::cache_latest_view<std::views::all_t<std::vector<int>>>>);
+
+static_assert(std::same_as<decltype(std::ranges::cache_latest_view(std::declval<std::vector<int>&>())),
+                           std::ranges::cache_latest_view<std::views::all_t<std::vector<int>&>>>);
+
+static_assert(std::same_as<decltype(std::ranges::cache_latest_view(std::ranges::empty_view<int>{})),
+                           std::ranges::cache_latest_view<std::ranges::empty_view<int>>>);
----------------
Zingam wrote:

```suggestion
                           std::ranges::cache_latest_view<std::ranges::empty_view<int>>>);

```

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


More information about the libcxx-commits mailing list