This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: First patch to simplify <algorithm>
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: caj <caj at cs dot york dot ac dot uk>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: 05 Dec 2004 15:49:11 +0100
- Subject: Re: First patch to simplify <algorithm>
- Organization: Integrable Solutions
- References: <41B3163C.4030401@cs.york.ac.uk>
caj <caj@cs.york.ac.uk> writes:
| + template<typename _ForwardIterator>
| + _ForwardIterator
| + adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
| + {
| + // concept requirements
| + __glibcxx_function_requires(_EqualityComparableConcept<
| + typename iterator_traits<_ForwardIterator>::value_type>)
| + return adjacent_find(__first, __last,
| + __default_eq_pred<typename iterator_traits<_ForwardIterator>::
| + value_type>());
With the suggestions I made, the above simply reads
return std::adjacent_find(__first, __last, __gnu_cxx::equal());
No, typename-fu. You can leave the "concept checking" part to the
"forwarded-to" more general algorithm. And you should make the
resulting function inline.
(Note the explicit qualification, too.)
-- gaby