[libcxx-commits] [libcxx] [libc++][NFC] Fix: Empty namespaces should be avoided (PR #210624)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jul 19 13:09:45 PDT 2026


https://github.com/H-G-Hristov created https://github.com/llvm/llvm-project/pull/210624

Context: Including `<__utility/cmp.h>` causes:

> cmp.h:25:1: error: Empty namespaces should be avoided. Move any checks around the namespace instead. [libcpp-avoid-empty-namespaces,-warnings-as-errors]

>From 6c6f15db0451f58cd2b2af7b644cd3cc29e41dbd Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 19 Jul 2026 23:09:25 +0300
Subject: [PATCH] [libc++][NFC] Fix: Empty namespaces should be avoided

Context: Including `<__utility/cmp.h>` causes:

> cmp.h:25:1: error: Empty namespaces should be avoided. Move any checks around the namespace instead. [libcpp-avoid-empty-namespaces,-warnings-as-errors]
---
 libcxx/include/__utility/cmp.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libcxx/include/__utility/cmp.h b/libcxx/include/__utility/cmp.h
index 7cfe640ceb423..360cf2eaa2aa4 100644
--- a/libcxx/include/__utility/cmp.h
+++ b/libcxx/include/__utility/cmp.h
@@ -22,10 +22,10 @@
 _LIBCPP_PUSH_MACROS
 #include <__undef_macros>
 
-_LIBCPP_BEGIN_NAMESPACE_STD
-
 #if _LIBCPP_STD_VER >= 20
 
+_LIBCPP_BEGIN_NAMESPACE_STD
+
 template <typename _Tp, typename _Ip>
 concept __comparison_can_promote_to =
     sizeof(_Tp) < sizeof(_Ip) || (sizeof(_Tp) == sizeof(_Ip) && __signed_integer<_Tp>);
@@ -84,10 +84,10 @@ template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up>
          std::cmp_greater_equal(__u, numeric_limits<_Tp>::min());
 }
 
-#endif // _LIBCPP_STD_VER >= 20
-
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // _LIBCPP_STD_VER >= 20
+
 _LIBCPP_POP_MACROS
 
 #endif // _LIBCPP___UTILITY_CMP_H



More information about the libcxx-commits mailing list