[libcxx-commits] [libcxx] [libc++] Implement a type-safe iterator for optional (PR #154239)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 5 08:57:51 PST 2025
================
@@ -0,0 +1,174 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+/*
+ * __upper_bounded_iterator is an iterator that wraps an underlying iterator.
+ * It stores the underlying container type to prevent mixing iterators, and allow algorithms
+ * to optimize based on the underlying container type.
+ * It also stores the absolute maximum amount of elements the container can have, known at compile-time.
+ * As of writing, the only standard library containers which have this property are inplace_vector and optional.
+ */
----------------
ldionne wrote:
Let's use C++ style comments even for long comments!
https://github.com/llvm/llvm-project/pull/154239
More information about the libcxx-commits
mailing list