Remove default function template argument from the header.

GCC will treat the default function template arguments as a
compilation error if C++0x is not enabled.

This commit workaround the compilation error by moving the
SFINAE check to function argument instead of the template
argument.

llvm-svn: 200523
This commit is contained in:
Logan Chien 2014-01-31 09:30:46 +00:00
parent 10243c8907
commit 22747e621e

View File

@ -2666,23 +2666,21 @@ public:
"unique_ptr constructed with null function pointer deleter"); "unique_ptr constructed with null function pointer deleter");
} }
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Pp, template <class _Pp>
class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p,
> typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p) _NOEXCEPT
: __ptr_(__p) : __ptr_(__p)
{ {
static_assert(!is_pointer<deleter_type>::value, static_assert(!is_pointer<deleter_type>::value,
"unique_ptr constructed with null function pointer deleter"); "unique_ptr constructed with null function pointer deleter");
} }
template <class _Pp, template <class _Pp>
class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::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,
deleter_type, deleter_type,
typename add_lvalue_reference<const deleter_type>::type>::type __d) typename add_lvalue_reference<const deleter_type>::type>::type __d,
typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat())
_NOEXCEPT _NOEXCEPT
: __ptr_(__p, __d) {} : __ptr_(__p, __d) {}
@ -2693,10 +2691,10 @@ public:
_NOEXCEPT _NOEXCEPT
: __ptr_(pointer(), __d) {} : __ptr_(pointer(), __d) {}
template <class _Pp, template <class _Pp>
class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::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) typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat())
_NOEXCEPT _NOEXCEPT
: __ptr_(__p, _VSTD::move(__d)) : __ptr_(__p, _VSTD::move(__d))
{ {
@ -2811,10 +2809,10 @@ public:
} }
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Pp, template <class _Pp>
class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type _LIBCPP_INLINE_VISIBILITY
> typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, void>::type
_LIBCPP_INLINE_VISIBILITY void reset(_Pp __p) _NOEXCEPT reset(_Pp __p) _NOEXCEPT
{ {
pointer __tmp = __ptr_.first(); pointer __tmp = __ptr_.first();
__ptr_.first() = __p; __ptr_.first() = __p;
@ -3759,27 +3757,15 @@ private:
public: public:
_LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT; _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT;
_LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT;
template<class _Yp, template<class _Yp>
class = typename enable_if explicit shared_ptr(_Yp* __p,
< typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
is_convertible<_Yp*, element_type*>::value template<class _Yp, class _Dp>
>::type shared_ptr(_Yp* __p, _Dp __d,
> typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
explicit shared_ptr(_Yp* __p); template<class _Yp, class _Dp, class _Alloc>
template<class _Yp, class _Dp, shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
class = typename enable_if typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
<
is_convertible<_Yp*, element_type*>::value
>::type
>
shared_ptr(_Yp* __p, _Dp __d);
template<class _Yp, class _Dp, class _Alloc,
class = typename enable_if
<
is_convertible<_Yp*, element_type*>::value
>::type
>
shared_ptr(_Yp* __p, _Dp __d, _Alloc __a);
template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d);
template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a);
template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT;
@ -3797,59 +3783,52 @@ public:
template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r,
typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat());
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template<class _Yp, template<class _Yp>
class = typename enable_if shared_ptr(auto_ptr<_Yp>&& __r,
< typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
is_convertible<_Yp*, element_type*>::value
>::type
>
shared_ptr(auto_ptr<_Yp>&& __r);
#else #else
template<class _Yp, template<class _Yp>
class = typename enable_if shared_ptr(auto_ptr<_Yp> __r,
< typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
is_convertible<_Yp*, element_type*>::value
>::type
>
shared_ptr(auto_ptr<_Yp> __r);
#endif #endif
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Yp, class _Dp, template <class _Yp, class _Dp>
class = typename enable_if shared_ptr(unique_ptr<_Yp, _Dp>&&,
< typename enable_if
!is_array<_Yp>::value && <
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value !is_lvalue_reference<_Dp>::value &&
>::type !is_array<_Yp>::value &&
> is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
shared_ptr(unique_ptr<_Yp, _Dp>&&, __nat
typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); >::type = __nat());
template <class _Yp, class _Dp, template <class _Yp, class _Dp>
class = typename enable_if shared_ptr(unique_ptr<_Yp, _Dp>&&,
< typename enable_if
!is_array<_Yp>::value && <
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value is_lvalue_reference<_Dp>::value &&
>::type !is_array<_Yp>::value &&
> is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
shared_ptr(unique_ptr<_Yp, _Dp>&&, __nat
typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); >::type = __nat());
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Yp, class _Dp, template <class _Yp, class _Dp>
class = typename enable_if shared_ptr(unique_ptr<_Yp, _Dp>,
< typename enable_if
!is_array<_Yp>::value && <
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value !is_lvalue_reference<_Dp>::value &&
>::type !is_array<_Yp>::value &&
> shared_ptr(unique_ptr<_Yp, _Dp>, is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); __nat
template <class _Yp, class _Dp, >::type = __nat());
class = typename enable_if template <class _Yp, class _Dp>
< shared_ptr(unique_ptr<_Yp, _Dp>,
!is_array<_Yp>::value && typename enable_if
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value <
>::type is_lvalue_reference<_Dp>::value &&
> !is_array<_Yp>::value &&
shared_ptr(unique_ptr<_Yp, _Dp>, is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); __nat
>::type = __nat());
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~shared_ptr(); ~shared_ptr();
@ -4039,8 +4018,9 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT
} }
template<class _Tp> template<class _Tp>
template<class _Yp, class> template<class _Yp>
shared_ptr<_Tp>::shared_ptr(_Yp* __p) shared_ptr<_Tp>::shared_ptr(_Yp* __p,
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
: __ptr_(__p) : __ptr_(__p)
{ {
unique_ptr<_Yp> __hold(__p); unique_ptr<_Yp> __hold(__p);
@ -4051,8 +4031,9 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p)
} }
template<class _Tp> template<class _Tp>
template<class _Yp, class _Dp, class> template<class _Yp, class _Dp>
shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d) shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d,
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
: __ptr_(__p) : __ptr_(__p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef _LIBCPP_NO_EXCEPTIONS
@ -4094,8 +4075,9 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d)
} }
template<class _Tp> template<class _Tp>
template<class _Yp, class _Dp, class _Alloc, class> template<class _Yp, class _Dp, class _Alloc>
shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
: __ptr_(__p) : __ptr_(__p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef _LIBCPP_NO_EXCEPTIONS
@ -4208,12 +4190,13 @@ shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r,
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template<class _Tp> template<class _Tp>
template<class _Yp, class> template<class _Yp>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r) shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r,
#else #else
shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r) shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r,
#endif #endif
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
: __ptr_(__r.get()) : __ptr_(__r.get())
{ {
typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
@ -4223,13 +4206,19 @@ shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r)
} }
template<class _Tp> template<class _Tp>
template <class _Yp, class _Dp, class> template <class _Yp, class _Dp>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
#else #else
shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
#endif #endif
typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type) typename enable_if
<
!is_lvalue_reference<_Dp>::value &&
!is_array<_Yp>::value &&
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
__nat
>::type)
: __ptr_(__r.get()) : __ptr_(__r.get())
{ {
typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
@ -4239,13 +4228,19 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
} }
template<class _Tp> template<class _Tp>
template <class _Yp, class _Dp, class> template <class _Yp, class _Dp>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
#else #else
shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
#endif #endif
typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type) typename enable_if
<
is_lvalue_reference<_Dp>::value &&
!is_array<_Yp>::value &&
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
__nat
>::type)
: __ptr_(__r.get()) : __ptr_(__r.get())
{ {
typedef __shared_ptr_pointer<_Yp*, typedef __shared_ptr_pointer<_Yp*,