Allow unique_ptr<T const []> to be constructed with a T* (in addition to a const T*)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@146736 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8e50a9cf73
commit
0a63119a76
@ -2498,6 +2498,24 @@ private:
|
|||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
unique_ptr(const unique_ptr&);
|
unique_ptr(const unique_ptr&);
|
||||||
unique_ptr& operator=(const unique_ptr&);
|
unique_ptr& operator=(const unique_ptr&);
|
||||||
|
|
||||||
|
template <class _P1,
|
||||||
|
bool = is_same<typename remove_cv<typename pointer_traits<_P1>::element_type>::type,
|
||||||
|
typename remove_cv<element_type>::type>::value>
|
||||||
|
struct __same_or_less_cv_qualified_imp
|
||||||
|
: is_convertible<_P1, pointer> {};
|
||||||
|
template <class _P1>
|
||||||
|
struct __same_or_less_cv_qualified_imp<_P1, false>
|
||||||
|
: false_type {};
|
||||||
|
|
||||||
|
template <class _P1, bool = is_scalar<_P1>::value && !is_pointer<_P1>::value>
|
||||||
|
struct __same_or_less_cv_qualified
|
||||||
|
: __same_or_less_cv_qualified_imp<_P1> {};
|
||||||
|
|
||||||
|
template <class _P1>
|
||||||
|
struct __same_or_less_cv_qualified<_P1, true>
|
||||||
|
: false_type {};
|
||||||
|
|
||||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
unique_ptr(unique_ptr&);
|
unique_ptr(unique_ptr&);
|
||||||
template <class _Up>
|
template <class _Up>
|
||||||
@ -2526,7 +2544,7 @@ public:
|
|||||||
}
|
}
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
template <class _Pp,
|
template <class _Pp,
|
||||||
class = typename enable_if<is_same<_Pp, pointer>::value>::type
|
class = typename enable_if<__same_or_less_cv_qualified<_Pp>::value>::type
|
||||||
>
|
>
|
||||||
_LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p) _NOEXCEPT
|
_LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p) _NOEXCEPT
|
||||||
: __ptr_(__p)
|
: __ptr_(__p)
|
||||||
@ -2536,7 +2554,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class _Pp,
|
template <class _Pp,
|
||||||
class = typename enable_if<is_same<_Pp, pointer>::value>::type
|
class = typename enable_if<__same_or_less_cv_qualified<_Pp>::value>::type
|
||||||
>
|
>
|
||||||
_LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional<
|
_LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional<
|
||||||
is_reference<deleter_type>::value,
|
is_reference<deleter_type>::value,
|
||||||
@ -2553,7 +2571,7 @@ public:
|
|||||||
: __ptr_(pointer(), __d) {}
|
: __ptr_(pointer(), __d) {}
|
||||||
|
|
||||||
template <class _Pp,
|
template <class _Pp,
|
||||||
class = typename enable_if<is_same<_Pp, pointer>::value ||
|
class = typename enable_if<__same_or_less_cv_qualified<_Pp>::value ||
|
||||||
is_same<_Pp, nullptr_t>::value>::type
|
is_same<_Pp, nullptr_t>::value>::type
|
||||||
>
|
>
|
||||||
_LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename remove_reference<deleter_type>::type&& __d)
|
_LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename remove_reference<deleter_type>::type&& __d)
|
||||||
@ -2637,7 +2655,7 @@ public:
|
|||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
template <class _Pp,
|
template <class _Pp,
|
||||||
class = typename enable_if<is_same<_Pp, pointer>::value>::type
|
class = typename enable_if<__same_or_less_cv_qualified<_Pp>::value>::type
|
||||||
>
|
>
|
||||||
_LIBCPP_INLINE_VISIBILITY void reset(_Pp __p) _NOEXCEPT
|
_LIBCPP_INLINE_VISIBILITY void reset(_Pp __p) _NOEXCEPT
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user