| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
|
| 3 |
template<typename T> |
| 4 |
T&& declval() noexcept; |
| 5 |
|
| 6 |
template<bool B> |
| 7 |
struct bool_constant |
| 8 |
{ |
| 9 |
static constexpr bool value = B; |
| 10 |
using type = bool_constant; |
| 11 |
}; |
| 12 |
|
| 13 |
using true_type = bool_constant<true>; |
| 14 |
using false_type = bool_constant<false>; |
| 15 |
|
| 16 |
template<bool, typename T, typename Arg> |
| 17 |
struct __is_nt_constructible_impl |
| 18 |
: public false_type |
| 19 |
{ }; |
| 20 |
|
| 21 |
template<typename T, typename Arg> |
| 22 |
struct __is_nt_constructible_impl<true, T, Arg> |
| 23 |
: public bool_constant<noexcept(static_cast<T>(declval<Arg>()))> |
| 24 |
{ }; |
| 25 |
|
| 26 |
template<typename T, typename Arg> |
| 27 |
using __is_nothrow_constructible_impl |
| 28 |
= __is_nt_constructible_impl<__is_constructible(T, Arg), T, Arg>; |
| 29 |
|
| 30 |
template<typename T> |
| 31 |
struct __is_nothrow_copy_constructible_impl |
| 32 |
: public __is_nothrow_constructible_impl<T, const T&> |
| 33 |
{ }; |
| 34 |
|
| 35 |
template<typename T> |
| 36 |
struct is_nothrow_copy_constructible |
| 37 |
: public __is_nothrow_copy_constructible_impl<T>::type |
| 38 |
{ }; |
| 39 |
|
| 40 |
template<bool, typename T, typename Arg> |
| 41 |
struct __is_nt_assignable_impl |
| 42 |
: public false_type |
| 43 |
{ }; |
| 44 |
|
| 45 |
template<typename T, typename Arg> |
| 46 |
struct __is_nt_assignable_impl<true, T, Arg> |
| 47 |
: public bool_constant<noexcept(declval<T&>() = declval<Arg>())> |
| 48 |
{ }; |
| 49 |
|
| 50 |
template<typename T, typename Arg> |
| 51 |
using __is_nothrow_assignable_impl |
| 52 |
= __is_nt_assignable_impl<__is_assignable(T, Arg), T, Arg>; |
| 53 |
|
| 54 |
template<typename T> |
| 55 |
struct __is_nothrow_copy_assignable_impl |
| 56 |
: public __is_nothrow_assignable_impl<T, const T&> |
| 57 |
{ }; |
| 58 |
|
| 59 |
template<typename T> |
| 60 |
struct is_nothrow_copy_assignable |
| 61 |
: public __is_nothrow_copy_assignable_impl<T>::type |
| 62 |
{ }; |
| 63 |
|
| 64 |
struct NType |
| 65 |
{ |
| 66 |
NType(); |
| 67 |
private: |
| 68 |
NType(const NType&); |
| 69 |
NType& operator=(const NType&); |
| 70 |
}; |
| 71 |
|
| 72 |
|
| 73 |
static_assert( !is_nothrow_copy_constructible<NType>::value, "" ); |
| 74 |
static_assert( !is_nothrow_copy_assignable<NType>::value, "" ); |