[libcxx-commits] [libcxx] Make std::nullopt_t comparable (PR #195549)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun May 3 13:31:06 PDT 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 -- libcxx/include/optional libcxx/test/std/utilities/optional/optional.nullopt/nullopt_t.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 424f5dd07..0f9262dc3 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -363,9 +363,9 @@ struct nullopt_t {
};
_LIBCPP_HIDE_FROM_ABI constexpr explicit nullopt_t(__secret_tag, __secret_tag) noexcept {}
_LIBCPP_HIDE_FROM_ABI constexpr nullopt_t(const nullopt_t&) noexcept = default;
-#if _LIBCPP_STD_VER >= 26
+# if _LIBCPP_STD_VER >= 26
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const nullopt_t&) const noexcept = default;
-#endif
+# endif
};
inline constexpr nullopt_t nullopt{nullopt_t::__secret_tag{}, nullopt_t::__secret_tag{}};
diff --git a/libcxx/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp b/libcxx/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
index 7fd1bbb95..1a54941cd 100644
--- a/libcxx/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
@@ -20,9 +20,9 @@
#include <optional>
#include <type_traits>
#if _LIBCPP_STD_VER >= 26
-#include <vector>
-#include <ranges>
-#include <cassert>
+# include <vector>
+# include <ranges>
+# include <cassert>
#endif
#include "test_macros.h"
@@ -54,10 +54,10 @@ int main(int, char**)
// Test ranges::find with nullopt
std::vector<std::optional<int>> v = {1, 2, nullopt, 4, 5};
- auto itr = std::ranges::find(v, nullopt);
+ auto itr = std::ranges::find(v, nullopt);
assert(itr != v.end());
assert(*itr == nullopt);
#endif
- return 0;
+ return 0;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/195549
More information about the libcxx-commits
mailing list