https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119415
--- Comment #8 from 康桓瑋 <hewillk at gmail dot com> --- (In reply to GCC Commits from comment #6) > The master branch has been updated by Tomasz Kaminski <tkami...@gcc.gnu.org>: > > https://gcc.gnu.org/g:4d1b19695669e6c67b9c3df07673bc22cae3a662 > > commit r15-8879-g4d1b19695669e6c67b9c3df07673bc22cae3a662 > Author: Tomasz KamiÅski <tkami...@redhat.com> > Date: Mon Mar 24 18:04:28 2025 +0100 > > libstdc++: Fix handling of common cpp20-only ranges for flat sets > [PR119415] > > These patch add check to verify if common range iterators satisfies > Cpp17LegacyIterator requirements (__detail::__cpp17_input_iterator), > before invoking overloads of insert that accepts two iterators. > As such overloads existed before c++20 iterators were introduced, > they commonly assume existence of iterator_traits<..>::iterator_category, > and passing a cpp20-only iterators, leads to hard errors. > > In case if user-defined container wants to support more efficient > insertion in such cases, it should provided insert_range method, > as in the case of standard containers. > > PR libstdc++/119415 > > libstdc++-v3/ChangeLog: > > * include/std/flat_set (_Flat_set_impl:insert_range): > Add __detail::__cpp17_input_iterator check. > * testsuite/23_containers/flat_multiset/1.cc: New tests > * testsuite/23_containers/flat_set/1.cc: New tests > > Reviewed-by: Patrick Palka <ppa...@redhat.com>, Jonathan Wakely > <jwak...@redhat.com> > Signed-off-by: Tomasz KamiÅski <tkami...@redhat.com> Hum, meeting Cpp17LegacyIterator requirements does not mean it is a C++17 input iterator, only iterator_traits<It>::iterator_category represents its category, so __cpp17_input_iterator should not be used here. We should use your first attempt here, i.e., iterator_traits<It>::iterator_category.