This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PR libstdc++/89102 implement new common_type rules (P0435R1, P0548R1)


This change ensures that std::common_type<> is a complete type (LWG
2408), and that std::common_type<T>, std::common_type<cv T1, cv T2>, and
std::common_type<T1, T2, R...> will use program-defined specializations
for std::common_type<T1, T2> (LWG 2465).

The implementation of common_type<T1, T2, R...> is changed to use
void_t, and the specializations for duration and time_point are modified
to also use void_t instead of depending on implementation details of
common_type.

	PR libstdc++/89102
	* doc/xml/manual/intro.xml: Document DR 2408 and 2465 changes.
	* include/std/chrono (__duration_common_type_wrapper): Replace with ...
	(__duration_common_type): New helper.
	(common_type<chrono::duration<R1, P2>, chrono::duration<R2, P2>>): Use
	__duration_common_type.
	(__timepoint_common_type_wrapper): Replace with ...
	(__timepoint_common_type): New helper.
	(common_type<chrono::time_point<C, D2>, chrono::time_point<C, D2>>):
	Use __time_point_common_type.
	* include/std/type_traits (common_type<>): Define, as per LWG 2408.
	(__common_type_impl): If either argument is transformed by decay,
	use the common_type of the decayed types.
	(__common_type_impl<_Tp, _Up, _Tp, _Up>): If the types are already
	decayed, use __do_common_type_impl to get the common_type.
	(common_type<_Tp>): Use common_type<_Tp, _Tp>.
	(__do_member_type_wrapper, __member_type_wrapper)
	(__expanded_common_type_wrapper): Remove.
	(__common_type_pack, __common_type_fold): New helpers.
	(common_type<_Tp, _Up, _Vp...>): Use new helpers instead of
	__member_type_wrapper and __expanded_common_type_wrapper.
	* testsuite/20_util/common_type/requirements/explicit_instantiation.cc:
	Test zero-length template argument list.
	* testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc:
	Test single argument cases and argument types that should decay.
	* testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc:
	Adjust expected error.
	* testsuite/20_util/duration/literals/range_neg.cc: Use zero for
	dg-error lineno.
	* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Likewise.
	* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise.
	* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise.

Tested powerpc64le-linux, committed to trunk.


Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]