[RFC] list::remove vs const& arguments...

Jonathan Wakely cow@compsoc.man.ac.uk
Tue Sep 14 13:24:00 GMT 2004


It would seem to be easy to fix std::list<T>::remove() by using a 
local copy of the value, since T is required to be CopyConstructible.

The same isn't true for std::remove() AFAICT.

But anyway ...

As an aside, why does std::remove() have this requirement?

      __glibcxx_function_requires(_ConvertibleConcept<_Tp,
            typename iterator_traits<_ForwardIterator>::value_type>)

This seems too restrictive to me - there's no assignment from _Tp
to the iterator's value_type, so why require the conversion?

The correct requirement is checked for

      __glibcxx_function_requires(_EqualOpConcept<
            typename iterator_traits<_ForwardIterator>::value_type, _Tp>)

so the right thing to do would seem to be to remove the check for
Convertible.

2004-09-14  Jonathan Wakely

	* include/bits/stl_algo.h: Remove too restrictive concept-check.

OK for mainline?
I don't think this is a regression, as it's been this way for ages,
but only matters when _GLIBCXX_CONCEPT_CHECKS is defined... 3.4 too?

jon

-- 
"There are books in which the footnotes, or the comments scrawled by some 
 reader's hand in the margin, are more interesting than the text. The world 
 is one of those books."
	- George Santayana
-------------- next part --------------
Index: include/bits/stl_algo.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_algo.h,v
retrieving revision 1.43.4.1
diff -u -p -b -B -r1.43.4.1 stl_algo.h
--- include/bits/stl_algo.h	18 Mar 2004 17:36:54 -0000	1.43.4.1
+++ include/bits/stl_algo.h	14 Sep 2004 13:20:24 -0000
@@ -1103,8 +1103,6 @@ namespace std
       // concept requirements
       __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
 				  _ForwardIterator>)
-      __glibcxx_function_requires(_ConvertibleConcept<_Tp,
-	    typename iterator_traits<_ForwardIterator>::value_type>)
       __glibcxx_function_requires(_EqualOpConcept<
 	    typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
       __glibcxx_requires_valid_range(__first, __last);


More information about the Libstdc++ mailing list