[libcxx-commits] [libcxx] [libc++] Make optional::iterator experimental (PR #173470)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 6 08:16:20 PST 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions ,cpp,h -- libcxx/include/__configuration/experimental.h libcxx/include/optional libcxx/include/version libcxx/test/libcxx/experimental/fexperimental-library.compile.pass.cpp libcxx/test/libcxx/utilities/optional/nodiscard.verify.cpp libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/test/std/utilities/optional/optional.iterator/begin.pass.cpp libcxx/test/std/utilities/optional/optional.iterator/borrowed_range.compile.pass.cpp libcxx/test/std/utilities/optional/optional.iterator/end.pass.cpp libcxx/test/std/utilities/optional/optional.iterator/iterator.pass.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/optional b/libcxx/include/optional
index 88debedf4..5f8ac4e89 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -715,38 +715,38 @@ public:
# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
using iterator = __bounded_iter<__wrap_iter<__pointer>>;
using const_iterator = __bounded_iter<__wrap_iter<__const_pointer>>;
-# else
+# else
using iterator = __wrap_iter<__pointer>;
using const_iterator = __wrap_iter<__const_pointer>;
-# endif
+# endif
// [optional.iterators], iterator support
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() noexcept {
auto& __derived_self = static_cast<optional<_Tp>&>(*this);
auto* __ptr = std::addressof(__derived_self.__get());
-# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
+# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
return std::__make_bounded_iter(
__wrap_iter<__pointer>(__ptr),
__wrap_iter<__pointer>(__ptr),
__wrap_iter<__pointer>(__ptr) + (__derived_self.has_value() ? 1 : 0));
-# else
+# else
return iterator(__ptr);
-# endif
+# endif
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const_iterator begin() const noexcept {
auto& __derived_self = static_cast<const optional<_Tp>&>(*this);
auto* __ptr = std::addressof(__derived_self.__get());
-# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
+# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
return std::__make_bounded_iter(
__wrap_iter<__const_pointer>(__ptr),
__wrap_iter<__const_pointer>(__ptr),
__wrap_iter<__const_pointer>(__ptr) + (__derived_self.has_value() ? 1 : 0));
-# else
+# else
return const_iterator(__ptr);
-# endif
+# endif
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator end() noexcept {
``````````
</details>
https://github.com/llvm/llvm-project/pull/173470
More information about the libcxx-commits
mailing list