@@ -130,6 +130,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
public:
+ using _DeleterConstraint = enable_if<
+ __and_<__not_<is_pointer<_Dp>, is_default_constructible<_Dp>>>::value>;
+
using pointer = typename _Ptr<_Tp, _Dp>::type;
__uniq_ptr_impl() = default;
@@ -152,6 +155,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template <typename _Tp, typename _Dp = default_delete<_Tp>>
class unique_ptr
{
+ using _DeleterConstraint = __uniq_ptr_impl<_Tp, _Dp>::_DeleterConstraint;
+
__uniq_ptr_impl<_Tp, _Dp> _M_t;
public:
@@ -175,10 +180,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Constructors.
/// Default constructor, creates a unique_ptr that owns nothing.
- constexpr unique_ptr() noexcept
- : _M_t()
- { static_assert(!is_pointer<deleter_type>::value,
- "constructed with null function pointer deleter"); }
+ template<typename = typename _DeleterConstraint::type>
+ constexpr unique_ptr() noexcept
+ : _M_t()
+ { }
/** Takes ownership of a pointer.
*
@@ -186,11 +191,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*
* The deleter will be value-initialized.
*/
- explicit
- unique_ptr(pointer __p) noexcept
- : _M_t(__p)
- { static_assert(!is_pointer<deleter_type>::value,
- "constructed with null function pointer deleter"); }
+ template<typename = typename _DeleterConstraint::type>
+ explicit
+ unique_ptr(pointer __p) noexcept
+ : _M_t(__p)
+ { }
/** Takes ownership of a pointer.
*
@@ -218,7 +223,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
"rvalue deleter bound to reference"); }
/// Creates a unique_ptr that owns nothing.
- constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
+ template<typename = typename _DeleterConstraint::type>
+ constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
// Move constructors.