P0805R1 is about comparing heterogenous containers.
This is the implementation for array, vector, deque, list and forward_list.
The tuple bits will follow soon.
I hope to land this immediately after it is adopted in Jacksonville.
Paths
| Differential D43773
Implement the container bits of P0805R1 Needs ReviewPublic Authored by mclow.lists on Feb 26 2018, 11:42 AM.
Details
Diff Detail Event TimelineComment Actions Hmm, for vector and deque, we define a temporary variable, check that sizes match and then use range-and-a-half equal: const typename vector<_Tp1, _Allocator1>::size_type __sz = __x.size(); return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); For list we check that sizes match and then use range-and-a-half equal, but don't use a temporary variable: return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); For array we check that sizes match and then use dual-range equal: if (_Size1 != _Size2) return false; return _VSTD::equal(__x.begin(), __x.end(), __y.begin(), __y.end()); Is there a subtle reason for this inconsistency that I'm not seeing? Comment Actions
I suspect that it's because they were written at different times. I'm a fan of the four-legged bits, but in op== (except for forward_list we know the sizes are the same. Comment Actions Add the tuple bits. Regularize the equality comparisons of the containers; i.e, don't try to be clever - let the compiler be clever.
Revision Contents
Diff 136582 include/array
include/deque
include/forward_list
include/list
include/tuple
include/vector
test/std/containers/sequences/array/compare.fail.cpp
test/std/containers/sequences/array/compare.pass.cpp
test/std/containers/sequences/deque/compare.fail.cpp
test/std/containers/sequences/deque/compare.pass.cpp
test/std/containers/sequences/forwardlist/compare.fail.cpp
test/std/containers/sequences/forwardlist/compare.pass.cpp
test/std/containers/sequences/list/compare.fail.cpp
test/std/containers/sequences/list/compare.pass.cpp
test/std/containers/sequences/vector/compare.fail.cpp
test/std/containers/sequences/vector/compare.pass.cpp
test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
|