Refactor throw_with_nested. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300197 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -202,46 +202,54 @@ struct __nested
|
|||||||
_LIBCPP_INLINE_VISIBILITY explicit __nested(const _Tp& __t) : _Tp(__t) {}
|
_LIBCPP_INLINE_VISIBILITY explicit __nested(const _Tp& __t) : _Tp(__t) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class _Tp>
|
|
||||||
_LIBCPP_NORETURN
|
|
||||||
void
|
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
throw_with_nested(_Tp&& __t, typename enable_if<
|
|
||||||
is_class<typename remove_reference<_Tp>::type>::value &&
|
|
||||||
!is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
|
|
||||||
&& !__libcpp_is_final<typename remove_reference<_Tp>::type>::value
|
|
||||||
>::type* = 0)
|
|
||||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
throw_with_nested (_Tp& __t, typename enable_if<
|
|
||||||
is_class<_Tp>::value && !is_base_of<nested_exception, _Tp>::value
|
|
||||||
>::type* = 0)
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
{
|
|
||||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||||
throw __nested<typename remove_reference<_Tp>::type>(_VSTD::forward<_Tp>(__t));
|
template <class _Tp, class _Up, bool>
|
||||||
#else
|
struct __throw_with_nested;
|
||||||
((void)__t);
|
|
||||||
// FIXME: Make this abort.
|
template <class _Tp, class _Up>
|
||||||
|
struct __throw_with_nested<_Tp, _Up, true> {
|
||||||
|
_LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void
|
||||||
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
|
__do_throw(_Tp&& __t)
|
||||||
|
#else
|
||||||
|
__do_throw (_Tp& __t)
|
||||||
|
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
|
{
|
||||||
|
throw __nested<_Up>(_VSTD::forward<_Tp>(__t));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Tp, class _Up>
|
||||||
|
struct __throw_with_nested<_Tp, _Up, false> {
|
||||||
|
_LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void
|
||||||
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
|
__do_throw(_Tp&& __t)
|
||||||
|
#else
|
||||||
|
__do_throw (_Tp& __t)
|
||||||
|
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
|
{
|
||||||
|
throw _VSTD::forward<_Tp>(__t);
|
||||||
|
}
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
_LIBCPP_NORETURN
|
_LIBCPP_NORETURN
|
||||||
void
|
void
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
throw_with_nested(_Tp&& __t, typename enable_if<
|
throw_with_nested(_Tp&& __t)
|
||||||
!is_class<typename remove_reference<_Tp>::type>::value ||
|
#else
|
||||||
is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
|
throw_with_nested (_Tp& __t)
|
||||||
|| __libcpp_is_final<typename remove_reference<_Tp>::type>::value
|
|
||||||
>::type* = 0)
|
|
||||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
throw_with_nested (_Tp& __t, typename enable_if<
|
|
||||||
!is_class<_Tp>::value || is_base_of<nested_exception, _Tp>::value
|
|
||||||
>::type* = 0)
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
{
|
{
|
||||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||||
throw _VSTD::forward<_Tp>(__t);
|
typedef typename remove_reference<_Tp>::type _Up;
|
||||||
|
// static_assert( is_copy_constructible<_Up>::value, "");
|
||||||
|
__throw_with_nested<_Tp, _Up,
|
||||||
|
is_class<_Up>::value &&
|
||||||
|
!is_base_of<nested_exception, _Up>::value &&
|
||||||
|
!__libcpp_is_final<_Up>::value>::
|
||||||
|
__do_throw(_VSTD::forward<_Tp>(__t));
|
||||||
#else
|
#else
|
||||||
((void)__t);
|
((void)__t);
|
||||||
// FIXME: Make this abort
|
// FIXME: Make this abort
|
||||||
|
|||||||
Reference in New Issue
Block a user