Skip to content
Snippets Groups Projects
Commit a9172b10 authored by Patrick Palka's avatar Patrick Palka
Browse files

libstdc++: Fix flat_foo::insert_range for non-common ranges [PR118156]


This fixes flat_map/multimap::insert_range by just generalizing the
insert implementation to handle heterogenous iterator/sentinel pair.
I'm not sure we can do better than this, e.g. we can't implement it in
terms of the adapted containers' insert_range because that'd require two
passes over the range.

For flat_set/multiset, we can implement insert_range directly in terms
of the adapted container's insert_range.  A fallback implementation
is also provided if insert_range isn't available, as is the case for
std::deque currently.

	PR libstdc++/118156

libstdc++-v3/ChangeLog:

	* include/std/flat_map (_Flat_map_impl::_M_insert): Generalized
	version of insert taking heterogenous iterator/sentinel pair.
	(_Flat_map_impl::insert): Dispatch to _M_insert.
	(_Flat_map_impl::insert_range): Likewise.
	(flat_map): Export _Flat_map_impl::insert_range.
	(flat_multimap): Likewise.
	* include/std/flat_set (_Flat_set_impl::insert_range):
	Reimplement directly, not in terms of insert.
	(flat_set): Export _Flat_set_impl::insert_range.
	(flat_multiset): Likewise.
	* testsuite/23_containers/flat_map/1.cc (test06): New test.
	* testsuite/23_containers/flat_multimap/1.cc (test06): New test.
	* testsuite/23_containers/flat_multiset/1.cc (test06): New test.
	* testsuite/23_containers/flat_set/1.cc (test06): New test.

Reviewed-by: default avatarJonathan Wakely <jwakely@redhat.com>
parent ee797739
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment