This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Remove algo code duplication


2012/4/28 François Dumont <frs.dumont@gmail.com>:
> ? ?Here is an other attempt to remove duplication of code in implementation
> of Standard algos. There are several enhancements on the last proposal:

Question: Isn't it necessary to put "less_aux" also into the implementations
namespace (like __less_aux)?

Shouldn't the now simply delegating function templates be declared inline (I do
not know the libstdc++ policy in this regard, so consider this more as
a question).

In one place you are using an explicit cast to bool as in

"__first1 != __last1 && bool(__binary_pred(*__first1, *__first2))"

but not in another place:

"__holeIndex > __topIndex
	     && __comp(*(__first + __parent), __value)"

IMO this should be done consistently.

Is similar consistency needed for something like

"if (__first == __middle || __middle == __last)"

as well? (This last example is more like a joke, because there are a big number
of these in the wild. I still ask, because some general guideline seems
appropriate)

In regard to "name mangling" of __ops components, I don't understand why
"__negate" has been captured (there seem to be no need, because std::negate
exists, and other names of library components like "equal_to" and "less" are
used). I suggest to unmangle __negate or use mangling consistently.

> 1. No usage of C++11 lambdas anymore, code works fine in C++98 and code has
> been really deleted this time. About 700 lines removed in stl_algo.h for
> instance.

I found a lambda expression used here:

+	std::__is_heap_until(__first,
+			     std::distance(__first, __last),
+			     [](typename _ItTraits::reference __lhs,
+				typename _ItTraits::reference __rhs)
+			     { return __lhs < __rhs; });

- Daniel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]