From 85c05b5eec703f9dd26e05215f336a3518b475df Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 15 May 2017 14:47:40 +0100 Subject: [PATCH] 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 --- libstdc++-v3/ChangeLog | 12 ++++++++++++ libstdc++-v3/include/bits/node_handle.h | 18 +----------------- libstdc++-v3/include/bits/stl_tree.h | 4 +++- .../testsuite/23_containers/map/modifiers/extract.cc | 11 +++++++++++ .../testsuite/23_containers/set/modifiers/extract.cc | 11 +++++++++++ .../23_containers/unordered_map/modifiers/extract.cc | 11 +++++++++++ .../23_containers/unordered_set/modifiers/extract.cc | 11 +++++++++++ 7 files changed, 60 insertions(+), 18 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8664e8c..4c6ca4b 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 44a9264..c7694a1 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 aedee06..3f133b0 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 507a708..80eaf01 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 c56767a..3fbc6b9 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 ad87c70..ce50766 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 6f77a94..5be8195 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() { -- 2.7.4