[llvm-branch-commits] [libcxx] 77d76b7 - [libc++] Fix recursive instantiation in std::array.

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jun 26 13:46:59 PDT 2020


Author: Eric Fiselier
Date: 2020-06-26T13:46:12-07:00
New Revision: 77d76b71d7df39b573dfa1e391096a040e9b7bd3

URL: https://github.com/llvm/llvm-project/commit/77d76b71d7df39b573dfa1e391096a040e9b7bd3
DIFF: https://github.com/llvm/llvm-project/commit/77d76b71d7df39b573dfa1e391096a040e9b7bd3.diff

LOG: [libc++] Fix recursive instantiation in std::array.

The use of the `&& ...` fold expression in std::array's deduction guides
recursively builds a set of binary operator expressions of depth N where
`N` is the number of elements in the initializer.

This is problematic because arrays may be large, and instantiation
depth is limited.

This patch addresses the issue by flattening the SFINAE using
the existing `__all` type trait.

(cherry picked from commit c6eb584c64872fbb779df14acd31c1f3947f6e52)

Added: 
    

Modified: 
    libcxx/include/array

Removed: 
    


################################################################################
diff  --git a/libcxx/include/array b/libcxx/include/array
index 88e9d57ff783..ddebf9159600 100644
--- a/libcxx/include/array
+++ b/libcxx/include/array
@@ -359,7 +359,7 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
 
 #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
 template<class _Tp, class... _Args,
-         class = typename enable_if<(is_same_v<_Tp, _Args> && ...), void>::type
+         class = _EnableIf<__all<_IsSame<_Tp, _Args>::value...>::value>
          >
 array(_Tp, _Args...)
   -> array<_Tp, 1 + sizeof...(_Args)>;


        


More information about the llvm-branch-commits mailing list