[libcxx] r300152 - Fix the default constructibility of __compressed_pair.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 12 17:50:46 PDT 2017


Author: ericwf
Date: Wed Apr 12 19:50:45 2017
New Revision: 300152

URL: http://llvm.org/viewvc/llvm-project?rev=300152&view=rev
Log:
Fix the default constructibility of __compressed_pair.

This patch fixes a bug where the =default default ctor for
__compressed_pair was incorrect for const qualified types.

Modified:
    libcxx/trunk/include/memory

Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=300152&r1=300151&r2=300152&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Wed Apr 12 19:50:45 2017
@@ -2079,7 +2079,13 @@ struct __compressed_pair_elem {
   typedef const _Tp& const_reference;
 
 #ifndef _LIBCPP_CXX03_LANG
-  __compressed_pair_elem() = default;
+  template <bool _Dummy = true, class = typename enable_if<
+      __dependent_type<is_default_constructible<_Tp>, _Dummy>::value
+    >::type
+  >
+  _LIBCPP_CONSTEXPR __compressed_pair_elem()
+      _NOEXCEPT_(is_nothrow_default_constructible<_Tp>::value)
+    : __value_() {}
 
   template <class _Up, class = typename enable_if<
                            !is_same<__compressed_pair_elem, _Up>::value>::type>
@@ -2112,7 +2118,7 @@ struct __compressed_pair_elem<_Tp, _Idx,
   typedef _Tp __value_type;
 
 #ifndef _LIBCPP_CXX03_LANG
-  __compressed_pair_elem() = default;
+  _LIBCPP_CONSTEXPR __compressed_pair_elem() = default;
 
   template <class _Up, class = typename enable_if<
                            !is_same<__compressed_pair_elem, _Up>::value>::type>




More information about the cfe-commits mailing list