Simplify the base characteristics for some type traits

* include/std/type_traits (__is_member_object_pointer_helper): Use
	__not_<is_function<_Tp>>::type instead of integral_constant.
	(__is_member_function_pointer_helper): Likewise for
	is_function<_Tp>::type.
	(is_compund): Likewise for __not_<is_fundamental<_Tp>>::type.
	(__do_is_nt_destructible_impl): Use __bool_constant and reindent.
	(is_trivially_constructible): Remove redundant use of
	is_constructible.
	(__is_trivially_copy_assignable_impl): Remove redundant use of
	is_copy_assignable.
	(__is_trivially_move_assignable_impl): Remove redundant use of
	is_move_assignable.
	(is_trivially_destructible): Use __bool_constant.
	* testsuite/20_util/is_trivially_assignable/value.cc: Add some more
	tests for scalar types.

From-SVN: r262889
This commit is contained in:
Jonathan Wakely 2018-07-19 20:12:37 +01:00 committed by Jonathan Wakely
parent 20a0c4e3dc
commit c01f9216b7
3 changed files with 93 additions and 58 deletions

View File

@ -1,3 +1,21 @@
2018-07-19 Jonathan Wakely <jwakely@redhat.com>
* include/std/type_traits (__is_member_object_pointer_helper): Use
__not_<is_function<_Tp>>::type instead of integral_constant.
(__is_member_function_pointer_helper): Likewise for
is_function<_Tp>::type.
(is_compund): Likewise for __not_<is_fundamental<_Tp>>::type.
(__do_is_nt_destructible_impl): Use __bool_constant and reindent.
(is_trivially_constructible): Remove redundant use of
is_constructible.
(__is_trivially_copy_assignable_impl): Remove redundant use of
is_copy_assignable.
(__is_trivially_move_assignable_impl): Remove redundant use of
is_move_assignable.
(is_trivially_destructible): Use __bool_constant.
* testsuite/20_util/is_trivially_assignable/value.cc: Add some more
tests for scalar types.
2018-07-19 Glen Joseph Fernandes <glenjofe@gmail.com>
* include/bits/stl_algobase.h (__copy_move_a): Used

View File

@ -396,7 +396,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Cp>
struct __is_member_object_pointer_helper<_Tp _Cp::*>
: public integral_constant<bool, !is_function<_Tp>::value> { };
: public __not_<is_function<_Tp>>::type { };
/// is_member_object_pointer
template<typename _Tp>
@ -411,7 +411,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Cp>
struct __is_member_function_pointer_helper<_Tp _Cp::*>
: public integral_constant<bool, is_function<_Tp>::value> { };
: public is_function<_Tp>::type { };
/// is_member_function_pointer
template<typename _Tp>
@ -603,7 +603,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// is_compound
template<typename _Tp>
struct is_compound
: public integral_constant<bool, !is_fundamental<_Tp>::value> { };
: public __not_<is_fundamental<_Tp>>::type { };
template<typename _Tp>
struct __is_member_pointer_helper
@ -826,8 +826,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __do_is_nt_destructible_impl
{
template<typename _Tp>
static integral_constant<bool, noexcept(declval<_Tp&>().~_Tp())>
__test(int);
static __bool_constant<noexcept(declval<_Tp&>().~_Tp())>
__test(int);
template<typename>
static false_type __test(...);
@ -1136,8 +1136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// is_trivially_constructible
template<typename _Tp, typename... _Args>
struct is_trivially_constructible
: public __and_<is_constructible<_Tp, _Args...>, __bool_constant<
__is_trivially_constructible(_Tp, _Args...)>>::type
: public __bool_constant<__is_trivially_constructible(_Tp, _Args...)>
{ };
/// is_trivially_default_constructible
@ -1235,9 +1234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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&)>>
: public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)>
{ };
template<typename _Tp>
@ -1256,9 +1253,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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&&)>>
: public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)>
{ };
template<typename _Tp>
@ -1269,8 +1264,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// is_trivially_destructible
template<typename _Tp>
struct is_trivially_destructible
: public __and_<is_destructible<_Tp>, integral_constant<bool,
__has_trivial_destructor(_Tp)>>
: public __and_<is_destructible<_Tp>,
__bool_constant<__has_trivial_destructor(_Tp)>>
{ };

View File

@ -44,91 +44,113 @@ void test01()
using std::is_trivially_assignable;
using namespace __gnu_test;
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
int, int>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
int&, int>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
int&, int&>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
int&, int&&>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
int&, const int&>(true), "");
static_assert(test_property<is_trivially_assignable,
int&, int*>(false), "");
static_assert(test_property<is_trivially_assignable,
int&, void*>(false), "");
static_assert(test_property<is_trivially_assignable,
const int, int>(false), "");
static_assert(test_property<is_trivially_assignable,
const int&, int>(false), "");
static_assert(test_property<is_trivially_assignable,
const int&, const int&>(false), "");
static_assert(test_property<is_trivially_assignable,
const int*&, int*>(true), "");
static_assert(test_property<is_trivially_assignable,
int*&, const int*&>(false), "");
static_assert(test_property<is_trivially_assignable,
int*&, const int&>(false), "");
static_assert(test_property<is_trivially_assignable,
const int*&, void*>(false), "");
static_assert(test_property<is_trivially_assignable,
const void*&, void*>(true), "");
static_assert(test_property<is_trivially_assignable,
const void*&, int*>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
TType, TType>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
TType&, TType>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
TType&, TType&>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
TType&, TType&&>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
TType&, const TType&>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
PODType, PODType>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
NType&, NType&>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
SLType, SLType>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::Empty, assign::Empty>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::Abstract, assign::Abstract>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::Ellipsis, assign::Ellipsis>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::DelEllipsis, assign::DelEllipsis>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::Any, assign::Any>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::DelDef, assign::DelDef>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::DelCopy, assign::DelCopy>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::Nontrivial, assign::Nontrivial>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::AnyAssign, assign::AnyAssign>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::DelAnyAssign, assign::DelAnyAssign>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::DelCopyAssign, assign::DelCopyAssign>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::MO, assign::MO>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::MO, assign::MO&&>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::MO, assign::MO&>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
assign::MO, const assign::MO&>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
CopyConsOnlyType, CopyConsOnlyType>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
CopyConsOnlyType, const CopyConsOnlyType&>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
MoveConsOnlyType, MoveConsOnlyType>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
MoveConsOnlyType, MoveConsOnlyType&&>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
HasTemplateCAssign, HasTemplateCAssign>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
HasTemplateCAssign, const HasTemplateCAssign&>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
ClassType, DerivedType>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
ClassType, DerivedType&>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
ClassType, DerivedType&&>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
ClassType, const DerivedType&>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
MoveOnly, MoveOnly>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
MoveOnly, MoveOnly&&>(true), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
MoveOnly, MoveOnly&>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
MoveOnly, const MoveOnly&>(false), "");
static_assert(test_property<is_trivially_assignable,
static_assert(test_property<is_trivially_assignable,
MoveOnly2, MoveOnly2>(false), "");
}