[libcxx-commits] [libcxx] 7a785d4 - [libc++][modules] Use inline variable instead of true_type (#106797)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 4 08:18:03 PDT 2024


Author: Louis Dionne
Date: 2024-09-04T11:18:00-04:00
New Revision: 7a785d46d6c31937c620f186464fdc59c265b4bf

URL: https://github.com/llvm/llvm-project/commit/7a785d46d6c31937c620f186464fdc59c265b4bf
DIFF: https://github.com/llvm/llvm-project/commit/7a785d46d6c31937c620f186464fdc59c265b4bf.diff

LOG: [libc++][modules] Use inline variable instead of true_type (#106797)

This allows breaking up a dependency from __fwd/array.h onto
__type_traits, which is a circular dependency once __type_traits becomes
a module of its own. This is also a small consistency improvement since
we've been using inline variables for traits like this elsewhere in the
library.

Added: 
    

Modified: 
    libcxx/include/__fwd/array.h
    libcxx/include/span

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__fwd/array.h b/libcxx/include/__fwd/array.h
index b429d0c5a95427..6c6461e7276040 100644
--- a/libcxx/include/__fwd/array.h
+++ b/libcxx/include/__fwd/array.h
@@ -35,11 +35,11 @@ template <size_t _Ip, class _Tp, size_t _Size>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT;
 #endif
 
-template <class>
-struct __is_std_array : false_type {};
+template <class _Tp>
+inline const bool __is_std_array_v = false;
 
 template <class _Tp, size_t _Size>
-struct __is_std_array<array<_Tp, _Size> > : true_type {};
+inline const bool __is_std_array_v<array<_Tp, _Size> > = true;
 
 _LIBCPP_END_NAMESPACE_STD
 

diff  --git a/libcxx/include/span b/libcxx/include/span
index da631cdc3f90e6..a32f7a372e2ae1 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -210,7 +210,7 @@ concept __span_compatible_range =
     ranges::contiguous_range<_Range> &&                             //
     ranges::sized_range<_Range> &&                                  //
     (ranges::borrowed_range<_Range> || is_const_v<_ElementType>) && //
-    !__is_std_array<remove_cvref_t<_Range>>::value &&               //
+    !__is_std_array_v<remove_cvref_t<_Range>> &&                    //
     !is_array_v<remove_cvref_t<_Range>> &&                          //
     is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>> (*)[], _ElementType (*)[]>;
 


        


More information about the libcxx-commits mailing list