Hi EricWF, howard.hinnant,
Eric Niebler proposed this as a fix for
http://llvm.org/bugs/show_bug.cgi?id=21917.
I've tested it, and found that it does solve the problem in the PR.
Note that this is (probably) a defect in the standard, and that this would be
an extension.
My concern is to make sure that this is (a) a conforming extension, and (b) not
an ABI change.
The standard says that the default constructor for pair requires that both
types be default-constructible.
I don't have tests for this (yet), but the program in the bug now compiles w/o
error.
http://reviews.llvm.org/D7384
Files:
include/utility
Index: include/utility
===================================================================
--- include/utility
+++ include/utility
@@ -260,7 +260,14 @@
// pair(const pair&) = default;
// pair(pair&&) = default;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {}
+ template<bool __b = true,
+ typename = typename enable_if<
+ std::is_default_constructible<_T1>::value
+ && std::is_default_constructible<_T2>::value
+ && __b>::type
+ >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ pair() : first(), second() {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(const _T1& __x, const _T2& __y)
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
Index: include/utility
===================================================================
--- include/utility
+++ include/utility
@@ -260,7 +260,14 @@
// pair(const pair&) = default;
// pair(pair&&) = default;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {}
+ template<bool __b = true,
+ typename = typename enable_if<
+ std::is_default_constructible<_T1>::value
+ && std::is_default_constructible<_T2>::value
+ && __b>::type
+ >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ pair() : first(), second() {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(const _T1& __x, const _T2& __y)
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits