Something about std::list<> member functions.
Gawain Bolton
gbolton@free.fr
Sat Aug 9 16:11:00 GMT 2003
Dhruv Matani wrote:
>I was wondering why in std::list<>, the functions merge, unique, sort,
>... are implemented twice, once for the less than operator, and once for
>the template argument one. Why can't it be coded just once for the more
>general version, and pass std::less<> to then more general one, when the
>less general one is called?
>
Good question! But this kind of thing is not limited to the std::list
class, the generic algorithms in stl_algobase.h and stl_algo.h also
currently have duplicated code for functions with and without comparison
objects or predicate objects as they're sometimes called.
Unless there is a good reason for not doing this, I would be happy to
submit a patch for std::list.
Cheers,
Gawain
More information about the Libstdc++
mailing list