[libcxx-commits] [libcxx] [libc++] P3168R2 Give std::optional Range Support (PR #146491)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 2 02:24:53 PDT 2025


================
@@ -578,6 +593,128 @@ struct __is_std_optional : false_type {};
 template <class _Tp>
 struct __is_std_optional<optional<_Tp>> : true_type {};
 
+#    if _LIBCPP_STD_VER >= 26
+
+template <class _T>
+constexpr bool ranges::enable_view<optional<_T>> = true;
+
+template <class _T>
+constexpr auto format_kind<optional<_T>> = range_format::disabled;
+
+template <typename _Tp>
+class __optional_iterator {
+  using _Base = __wrap_iter<_Tp*>;
----------------
dywoq wrote:

oh, I misunderstood you. I'll use __wrap-iter then

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


More information about the libcxx-commits mailing list