Commit 85c05b5e by Jonathan Wakely Committed by Jonathan Wakely

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
parent 51160482
2017-05-15 Jonathan Wakely <jwakely@redhat.com>
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 <jwakely@redhat.com>
PR libstdc++/78939
......
......@@ -280,8 +280,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Iterator, typename _NodeHandle>
struct _Node_insert_return
{
bool inserted = false;
_Iterator position = _Iterator();
bool inserted = false;
_NodeHandle node;
template<size_t _Idx>
......@@ -305,22 +305,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
};
template<typename _Iterator, typename _NodeHandle>
struct tuple_size<_Node_insert_return<_Iterator, _NodeHandle>>
: integral_constant<size_t, 3> { };
template<typename _Iterator, typename _NodeHandle>
struct tuple_element<0, _Node_insert_return<_Iterator, _NodeHandle>>
{ using type = bool; };
template<typename _Iterator, typename _NodeHandle>
struct tuple_element<1, _Node_insert_return<_Iterator, _NodeHandle>>
{ using type = _Iterator; };
template<typename _Iterator, typename _NodeHandle>
struct tuple_element<2, _Node_insert_return<_Iterator, _NodeHandle>>
{ using type = _NodeHandle; };
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
......
......@@ -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<iterator, node_type>;
using insert_return_type = _Node_insert_return<
conditional_t<is_same_v<_Key, _Val>, const_iterator, iterator>,
node_type>;
#endif
pair<_Base_ptr, _Base_ptr>
......
......@@ -135,6 +135,17 @@ test03()
static_assert( is_same_v<test_type::node_type, compat_type3::node_type> );
}
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<test_type::iterator, decltype(pos)> );
static_assert( is_same_v<bool, decltype(ins)> );
static_assert( is_same_v<test_type::node_type, decltype(node)> );
}
int
main()
{
......
......@@ -126,6 +126,17 @@ test03()
static_assert( is_same_v<test_type::node_type, compat_type3::node_type> );
}
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<test_type::iterator, decltype(pos)> );
static_assert( is_same_v<bool, decltype(ins)> );
static_assert( is_same_v<test_type::node_type, decltype(node)> );
}
int
main()
{
......
......@@ -136,6 +136,17 @@ test03()
static_assert( is_same_v<test_type::node_type, compat_type3::node_type> );
}
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<test_type::iterator, decltype(pos)> );
static_assert( is_same_v<bool, decltype(ins)> );
static_assert( is_same_v<test_type::node_type, decltype(node)> );
}
int
main()
{
......
......@@ -128,6 +128,17 @@ test03()
static_assert( is_same_v<test_type::node_type, compat_type3::node_type> );
}
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<test_type::iterator, decltype(pos)> );
static_assert( is_same_v<bool, decltype(ins)> );
static_assert( is_same_v<test_type::node_type, decltype(node)> );
}
int
main()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment