[C++ PATCH, RFC] Implement new C++ intrinsics __is_assignable and __is_constructible.
Jonathan Wakely
jwakely@redhat.com
Wed May 17 13:46:00 GMT 2017
On 17/05/17 15:15 +0300, Ville Voutilainen wrote:
>One more round. This patch doesn't change any of the compiler bits,
>but the llvm testsuite revealed
>that we didn't handle things like
>is_trivially_copy_constructible<void> properly, so I needed to adjust
>the library implementation of the triviality-traits. Now we pass the
>llvm testsuite for these traits,
>and this patch passes our full testsuite.
>
>Jonathan, ok for trunk?
Yes OK, thanks.
A few observations ...
>@@ -1405,45 +1185,95 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> { };
>
> /// is_trivially_copy_constructible
>+
>+ template<typename _Tp, bool = __is_referenceable<_Tp>::value>
>+ struct __is_trivially_copy_constructible_impl;
>+
> template<typename _Tp>
>- struct is_trivially_copy_constructible
>+ struct __is_trivially_copy_constructible_impl<_Tp, false>
>+ : public false_type { };
>+
>+ template<typename _Tp>
>+ struct __is_trivially_copy_constructible_impl<_Tp, true>
> : public __and_<is_copy_constructible<_Tp>,
> integral_constant<bool,
> __is_trivially_constructible(_Tp, const _Tp&)>>
> { };
This could use __bool_constant, and there doesn't seem to be any
advantage to using __and_ here, because there's nothing to
short-circuit. So:
: public __bool_constant<is_copy_constructible<_Tp>::value
&& __is_trivially_constructible(_Tp, const _Tp&)>
But that was pre-existing, so let's deal with that
separately.
>+ template<typename _Tp>
>+ struct __is_trivially_move_constructible_impl<_Tp, true>
> : public __and_<is_move_constructible<_Tp>,
> integral_constant<bool,
> __is_trivially_constructible(_Tp, _Tp&&)>>
> { };
Ditto.
>+ template<typename _Tp>
>+ struct __is_trivially_copy_assignable_impl<_Tp, true>
> : public __and_<is_copy_assignable<_Tp>,
> integral_constant<bool,
> __is_trivially_assignable(_Tp&, const _Tp&)>>
> { };
Ditto.
>+ template<typename _Tp>
>+ struct __is_trivially_move_assignable_impl<_Tp, true>
> : public __and_<is_move_assignable<_Tp>,
> integral_constant<bool,
> __is_trivially_assignable(_Tp&, _Tp&&)>>
Ditto.
More information about the Libstdc++
mailing list