From: Jonathan Wakely Date: Mon, 15 May 2017 13:47:40 +0000 (+0100) Subject: Fix order and types of members in C++17 insert_return_type structs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=85c05b5eec703f9dd26e05215f336a3518b475df;p=gcc.git Fix order and types of members in C++17 insert_return_type structs PR libstdc++/80761 * include/bits/node_handle.h (_Node_insert_return): Reorder members. (tuple_size, tuple_element): Remove partial specializations. * include/bits/stl_tree.h (_Rb_tree::insert_return_type): Use const_iterator for std::set. * testsuite/23_containers/map/modifiers/extract.cc: New. * testsuite/23_containers/set/modifiers/extract.cc: New. * testsuite/23_containers/unordered_map/modifiers/extract.cc: New. * testsuite/23_containers/unordered_set/modifiers/extract.cc: New. From-SVN: r248062 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8664e8cd525..4c6ca4b36be 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2017-05-15 Jonathan Wakely + + PR libstdc++/80761 + * include/bits/node_handle.h (_Node_insert_return): Reorder members. + (tuple_size, tuple_element): Remove partial specializations. + * include/bits/stl_tree.h (_Rb_tree::insert_return_type): Use + const_iterator for std::set. + * testsuite/23_containers/map/modifiers/extract.cc: New. + * testsuite/23_containers/set/modifiers/extract.cc: New. + * testsuite/23_containers/unordered_map/modifiers/extract.cc: New. + * testsuite/23_containers/unordered_set/modifiers/extract.cc: New. + 2017-05-12 Jonathan Wakely PR libstdc++/78939 diff --git a/libstdc++-v3/include/bits/node_handle.h b/libstdc++-v3/include/bits/node_handle.h index 44a92644cd5..c7694a1e0ef 100644 --- a/libstdc++-v3/include/bits/node_handle.h +++ b/libstdc++-v3/include/bits/node_handle.h @@ -280,8 +280,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct _Node_insert_return { - bool inserted = false; _Iterator position = _Iterator(); + bool inserted = false; _NodeHandle node; template @@ -305,22 +305,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } }; - template - struct tuple_size<_Node_insert_return<_Iterator, _NodeHandle>> - : integral_constant { }; - - template - struct tuple_element<0, _Node_insert_return<_Iterator, _NodeHandle>> - { using type = bool; }; - - template - struct tuple_element<1, _Node_insert_return<_Iterator, _NodeHandle>> - { using type = _Iterator; }; - - template - struct tuple_element<2, _Node_insert_return<_Iterator, _NodeHandle>> - { using type = _NodeHandle; }; - _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index aedee06be76..3f133b0dad0 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -812,7 +812,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L using node_type = _Node_handle<_Key, _Val, _Node_allocator>; - using insert_return_type = _Node_insert_return; + using insert_return_type = _Node_insert_return< + conditional_t, const_iterator, iterator>, + node_type>; #endif pair<_Base_ptr, _Base_ptr> diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/extract.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/extract.cc index 507a708eed8..80eaf018a70 100644 --- a/libstdc++-v3/testsuite/23_containers/map/modifiers/extract.cc +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/extract.cc @@ -135,6 +135,17 @@ test03() static_assert( is_same_v ); } +void +test04() +{ + // Check order of members in insert_return_type + auto [pos, ins, node] = test_type::insert_return_type{}; + using std::is_same_v; + static_assert( is_same_v ); + static_assert( is_same_v ); + static_assert( is_same_v ); +} + int main() { diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/extract.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/extract.cc index c56767a9a3e..3fbc6b9a798 100644 --- a/libstdc++-v3/testsuite/23_containers/set/modifiers/extract.cc +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/extract.cc @@ -126,6 +126,17 @@ test03() static_assert( is_same_v ); } +void +test04() +{ + // Check order of members in insert_return_type + auto [pos, ins, node] = test_type::insert_return_type{}; + using std::is_same_v; + static_assert( is_same_v ); + static_assert( is_same_v ); + static_assert( is_same_v ); +} + int main() { diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/extract.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/extract.cc index ad87c7096b8..ce50766b496 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/extract.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/extract.cc @@ -136,6 +136,17 @@ test03() static_assert( is_same_v ); } +void +test04() +{ + // Check order of members in insert_return_type + auto [pos, ins, node] = test_type::insert_return_type{}; + using std::is_same_v; + static_assert( is_same_v ); + static_assert( is_same_v ); + static_assert( is_same_v ); +} + int main() { diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/extract.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/extract.cc index 6f77a94d321..5be81951407 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/extract.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/extract.cc @@ -128,6 +128,17 @@ test03() static_assert( is_same_v ); } +void +test04() +{ + // Check order of members in insert_return_type + auto [pos, ins, node] = test_type::insert_return_type{}; + using std::is_same_v; + static_assert( is_same_v ); + static_assert( is_same_v ); + static_assert( is_same_v ); +} + int main() {