[libcxx-commits] [libcxx] e21ab31 - [libc++] Eliminate <compare>'s dependency on <array>.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 25 07:35:06 PDT 2021
Author: Arthur O'Dwyer
Date: 2021-03-25T10:34:35-04:00
New Revision: e21ab31f45a440e195f9c914083d57718e0de3b7
URL: https://github.com/llvm/llvm-project/commit/e21ab31f45a440e195f9c914083d57718e0de3b7
DIFF: https://github.com/llvm/llvm-project/commit/e21ab31f45a440e195f9c914083d57718e0de3b7.diff
LOG: [libc++] Eliminate <compare>'s dependency on <array>.
This refactor is not only a good idea, but is in fact required by the standard,
in the sense that <array> is mandated to include <compare>.
So <compare> shouldn't have a circular dependency on <array>!
Differential Revision: https://reviews.llvm.org/D99307
Added:
Modified:
libcxx/include/compare
Removed:
################################################################################
diff --git a/libcxx/include/compare b/libcxx/include/compare
index 048f4821dd4e..12c7aa0a740e 100644
--- a/libcxx/include/compare
+++ b/libcxx/include/compare
@@ -126,7 +126,6 @@ namespace std {
#include <__config>
#include <type_traits>
-#include <array>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
#pragma GCC system_header
@@ -701,8 +700,8 @@ constexpr _ClassifyCompCategory __type_to_enum() noexcept {
template <size_t _Size>
constexpr _ClassifyCompCategory
-__compute_comp_type(array<_ClassifyCompCategory, _Size> __types) {
- array<int, _CCC_Size> __seen = {};
+__compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) {
+ int __seen[_CCC_Size] = {};
for (auto __type : __types)
++__seen[__type];
if (__seen[_None])
@@ -723,9 +722,8 @@ __compute_comp_type(array<_ClassifyCompCategory, _Size> __types) {
template <class ..._Ts>
constexpr auto __get_comp_type() {
using _CCC = _ClassifyCompCategory;
- constexpr array<_CCC, sizeof...(_Ts)> __type_kinds{{__comp_detail::__type_to_enum<_Ts>()...}};
- constexpr _CCC _Cat = sizeof...(_Ts) == 0 ? _StrongOrd
- : __compute_comp_type(__type_kinds);
+ constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...};
+ constexpr _CCC _Cat = __compute_comp_type(__type_kinds);
if constexpr (_Cat == _None)
return void();
else if constexpr (_Cat == _WeakEq)
More information about the libcxx-commits
mailing list