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

Yanzuo Liu via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 1 05:26:46 PDT 2025


================
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: std-at-least-c++26
+
+#include <cassert>
+#include <optional>
+
+int main() {
+  std::optional<int> val = 2;
+  for (const auto& elem : val)
+    assert(elem == 2);
+  return 0;
+}
----------------
zwuis wrote:

Missing new line character at EOF.

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


More information about the libcxx-commits mailing list