From 5c2d2ad5454ad9b34c86cbb3d3b6aabe8b5000a3 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sun, 26 Jun 2022 04:50:00 +0700 Subject: [PATCH] add default ctor for node types (#2782) Co-authored-by: A. Jiang Co-authored-by: Casey Carter Co-authored-by: Stephan T. Lavavej --- stl/inc/forward_list | 5 +++-- stl/inc/list | 4 +++- stl/inc/type_traits | 9 +++------ stl/inc/xtree | 4 +++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/stl/inc/forward_list b/stl/inc/forward_list index e334451202..ce71eea9b3 100644 --- a/stl/inc/forward_list +++ b/stl/inc/forward_list @@ -241,9 +241,10 @@ template struct _Flist_node { // forward_list node using _Nodeptr = _Rebind_pointer_t<_Voidptr, _Flist_node>; - _Nodeptr _Next; // successor node - _Value_type _Myval; // the stored value + _Nodeptr _Next; + _Value_type _Myval = _Returns_exactly<_Value_type>(); // fake a viable constructor to workaround GH-2749 + _Flist_node() = default; _Flist_node(const _Flist_node&) = delete; _Flist_node& operator=(const _Flist_node&) = delete; diff --git a/stl/inc/list b/stl/inc/list index e5d0956d72..0884228fb2 100644 --- a/stl/inc/list +++ b/stl/inc/list @@ -289,8 +289,10 @@ struct _List_node { // list node using _Nodeptr = _Rebind_pointer_t<_Voidptr, _List_node>; _Nodeptr _Next; // successor node, or first element if head _Nodeptr _Prev; // predecessor node, or last element if head - _Value_type _Myval; // the stored value, unused if head + _Value_type _Myval = // the stored value, unused if head + _Returns_exactly<_Value_type>(); // fake a viable constructor to workaround GH-2749 + _List_node() = default; _List_node(const _List_node&) = delete; _List_node& operator=(const _List_node&) = delete; diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 8ac768676b..22780c2c8f 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1218,13 +1218,13 @@ struct _Common_type3>, _Ty1, _Ty2, _Rest...> template struct common_type<_Ty1, _Ty2, _Rest...> : _Common_type3 {}; +template +_Ty _Returns_exactly() noexcept; // not defined + #if _HAS_CXX20 template class, template class> struct basic_common_reference {}; -template -_Ty _Returns_exactly() noexcept; // not defined - template struct _Copy_cv_impl { template @@ -1614,9 +1614,6 @@ template using is_nothrow_convertible = _Is_nothrow_convertible<_From, _To>; #endif // _HAS_CXX20 -template -_Ty _Returns_exactly() noexcept; // not defined - template struct _Invoke_convertible : false_type {}; diff --git a/stl/inc/xtree b/stl/inc/xtree index 106ab11eea..ab7649521f 100644 --- a/stl/inc/xtree +++ b/stl/inc/xtree @@ -328,13 +328,15 @@ struct _Tree_node { _Nodeptr _Right; // right subtree, or largest element if head char _Color; // _Red or _Black, _Black if head char _Isnil; // true only if head (also nil) node; TRANSITION, should be bool - value_type _Myval; // the stored value, unused if head + value_type _Myval = // the stored value, unused if head + _Returns_exactly(); // fake a viable constructor to workaround GH-2749 enum _Redbl { // colors for link to parent _Red, _Black }; + _Tree_node() = default; _Tree_node(const _Tree_node&) = delete; _Tree_node& operator=(const _Tree_node&) = delete;