New antisymmetrical debug check
Daniel Krügler
daniel.kruegler@gmail.com
Thu Oct 22 19:41:00 GMT 2015
2015-10-22 21:18 GMT+02:00 François Dumont <frs.dumont@gmail.com>:
> Hi
>
> I leveraged on predefined operators to inject a new debug check for
> strict weak ordering operators. It checks that for a given functor f if
> f(a, b) then !f(b, a). In terms of < operator: if (a < b) assert(!(b < a)).
>
> I had to replace the generic functors like _Iter_comp_iter by more
> explicit _Iter_less_iter where this check can take place. As algos can
> be used with different iterator types those checks are only performed in
> C++11 and after to make sure that b < a is a valid expression.
[..]
> Tested under Linux x86_64.
>
> Ok to commit ?
I'm wondering: Why does the _M_reverse_check overload set require
_GLIBCXX14_CONSTEXPR and not _GLIBCXX11_CONSTEXPR? None of them is
written in a way that it could not be a valid C++11 constexpr
function?
I believe that operator()(_Iterator1 __it1, _Iterator2 __it2) could
easily be adapted to be also a valid C++11 constexpr function by
replacing the if-directive by an conditional expression and please
note that your __cplusplus tests are always C++11 compatible.
On the other hand in line 311 of the patch you define a
_GLIBCXX14_CONSTEXPR operator(), but that one seems to invoke
_M_reverse_check functions where none of them is constexpr, so this
operator() could never be constexpr. Note also that
_Iter_less_val_comp on line 306 doesn't have a constexpr constructor,
so there is no way to invoke the constexpr operator() member.
It seems as if a similar problem exists for line 377 and the following
_M_reverse_check overloads.
Comparing to these two, why is in line 136 and line 187 the operator()
template and it's _M_reverse_check not constexpr as well?
Thanks,
- Daniel
More information about the Libstdc++
mailing list