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] | |
On 11/04/15 13:44 +0100, Jonathan Wakely wrote:
we can't just add the check in the constructor of _Iter_to_comp_iter
where we have a dereferencable iterator and the functor:
--- bits/predefined_ops.h.orig 2015-04-11 13:28:30.063009877 +0100
+++ bits/predefined_ops.h 2015-04-11 13:28:33.645013410 +0100
@@ -268,7 +268,13 @@
_Iter_comp_to_iter(_Compare __comp, _Iterator1 __it1)
: _M_comp(__comp), _M_ref(*__it1)
- { }
+ {
+#ifdef _GLIBCXX_DEBUG
+ // Comparison must define a Strict Weak Ordering, like "less than",
+ // so must be irreflexive, i.e. x < x must be false.
+ __glibcxx_assert( !_M_cmp(_M_ref, _M_ref) );
+#endif
+ }
template<typename _Iterator2>
bool
That won't help std::sort, because it doesn't use _Iter_comp_to_iter.
Oh, that *definitely* won't work because _Iter_comp_to_iter is only used for equality comparisons not strict weak orderings, so checking for irreflexivity there is completely wrong :-)So ignore the patch above, but I think my main point is still valid, doing the check in the wrapper means we have to repeat it many times,
for very little benefit.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |