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> 2018-07-19 Glen Joseph Fernandes <glenjofe@gmail.com>
* include/bits/stl_algobase.h (__copy_move_a): Used * include/bits/stl_algobase.h (__copy_move_a): Used

View File

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

View File

@ -54,6 +54,28 @@ void test01()
int&, int&&>(true), ""); int&, int&&>(true), "");
static_assert(test_property<is_trivially_assignable, static_assert(test_property<is_trivially_assignable,
int&, const int&>(true), ""); 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), ""); TType, TType>(true), "");