[libcxx-commits] [libcxx] [libc++] Resolve LWG4370 (PR #174062)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 30 22:31:45 PST 2025


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/test/std/utilities/optional/optional.relops/relops.compile.pass.cpp libcxx/include/optional --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 6d21225f1..d77eb3cbc 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -1405,7 +1405,7 @@ template <
     enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,
                 int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, const _Up& __v) {
-  if(__x.has_value()) {
+  if (__x.has_value()) {
     return *__x == __v;
   }
   return false;
@@ -1417,7 +1417,7 @@ template <
     enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,
                 int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const _Tp& __v, const optional<_Up>& __x) {
-  if(__x.has_value()) {
+  if (__x.has_value()) {
     return __v == *__x;
   }
   return false;
@@ -1429,7 +1429,7 @@ template <
     enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>,
                 int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const optional<_Tp>& __x, const _Up& __v) {
-  if(__x.has_value()) {
+  if (__x.has_value()) {
     return *__x != __v;
   }
   return true;
@@ -1441,7 +1441,7 @@ template <
     enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>,
                 int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const _Tp& __v, const optional<_Up>& __x) {
-  if(__x.has_value()) {
+  if (__x.has_value()) {
     return __v != *__x;
   }
   return true;
@@ -1452,7 +1452,7 @@ template < class _Tp,
            enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>,
                        int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const optional<_Tp>& __x, const _Up& __v) {
-  if(__x.has_value()) {
+  if (__x.has_value()) {
     return *__x < __v;
   }
   return true;
@@ -1463,7 +1463,7 @@ template < class _Tp,
            enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>,
                        int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const _Tp& __v, const optional<_Up>& __x) {
-  if(__x.has_value()) {
+  if (__x.has_value()) {
     return __v < *__x;
   }
   return false;
@@ -1475,7 +1475,7 @@ template <
     enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>,
                 int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const optional<_Tp>& __x, const _Up& __v) {
-  if(__x.has_value()) {
+  if (__x.has_value()) {
     return *__x <= __v;
   }
   return true;
@@ -1487,7 +1487,7 @@ template <
     enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>,
                 int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const _Tp& __v, const optional<_Up>& __x) {
-  if(__x.has_value()) {
+  if (__x.has_value()) {
     return __v <= *__x;
   }
   return false;
@@ -1498,7 +1498,7 @@ template < class _Tp,
            enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>,
                        int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const optional<_Tp>& __x, const _Up& __v) {
-  if(__x.has_value()) {
+  if (__x.has_value()) {
     return *__x > __v;
   }
   return false;
@@ -1509,7 +1509,7 @@ template < class _Tp,
            enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>,
                        int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const _Tp& __v, const optional<_Up>& __x) {
-  if(__x.has_value()){
+  if (__x.has_value()) {
     return __v > *__x;
   }
   return true;
@@ -1521,7 +1521,7 @@ template <
     enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>,
                 int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const optional<_Tp>& __x, const _Up& __v) {
-  if(__x.has_value()) {
+  if (__x.has_value()) {
     return *__x >= __v;
   }
   return false;
@@ -1533,7 +1533,7 @@ template <
     enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>,
                 int> = 0>
 _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const _Tp& __v, const optional<_Up>& __x) {
-  if(__x.has_value()) {
+  if (__x.has_value()) {
     return __v >= *__x;
   }
   return true;

``````````

</details>


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


More information about the libcxx-commits mailing list