Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
732d748
Container spaceship changes, squashed.
ahanamuk Jul 15, 2020
06dfcd7
incorporated all comments from code review mainly changing ifdef guards
ahanamuk Jul 20, 2020
4ca3624
undid a change to iterator
ahanamuk Jul 20, 2020
17e650d
updated synth_three_way to a regular struct
ahanamuk Jul 21, 2020
c2ec451
Restore braces lost during merging.
StephanTLavavej Jul 23, 2020
3ed745d
Drop <iterator> changes from this PR.
StephanTLavavej Jul 23, 2020
b7e83a4
Adjust comment spacing.
StephanTLavavej Jul 23, 2020
fbc0f89
Update multimap and multiset guards.
StephanTLavavej Jul 23, 2020
3c9a1a0
Fix all spaceship guards; STL's guidance was bogus
StephanTLavavej Jul 23, 2020
f6c5510
vector spaceship needs _Synth_three_way{}.
StephanTLavavej Jul 23, 2020
1dc5c43
Fix queue/stack friendship.
StephanTLavavej Jul 23, 2020
f8ef466
Use unchecked iterators to implement comparisons.
StephanTLavavej Jul 23, 2020
dc3e324
Verify `decltype(smaller <=> larger)`.
StephanTLavavej Jul 24, 2020
b2c5086
Test varying element strengths.
StephanTLavavej Jul 24, 2020
0cfe696
Verify that containers use synth-three-way.
StephanTLavavej Jul 24, 2020
c9699e7
Work around VSO-1161663.
StephanTLavavej Jul 24, 2020
7538c77
Move vector swap/comparison below vector<bool>.
StephanTLavavej Jul 24, 2020
8858a09
Refactor the vector<bool> equality optimization.
StephanTLavavej Jul 24, 2020
1416165
Optimize vector<bool> spaceship and less-than.
StephanTLavavej Jul 24, 2020
015eae3
Minimally upgrade vector<bool> comparison testing.
StephanTLavavej Jul 25, 2020
cd9a610
Implement bit reversal.
StephanTLavavej Jul 25, 2020
9fd5169
Use _Countr_zero() for even more efficiency.
StephanTLavavej Jul 25, 2020
195536b
Further improve `_Vbase_compare_three_way` codegen.
StephanTLavavej Jul 25, 2020
664ac1b
Rename vector_bool_comparisons test.
StephanTLavavej Jul 28, 2020
d6acf3e
Test vector<bool> comparisons.
StephanTLavavej Jul 28, 2020
2059df3
Add forward declaration, move _Vbase/_VBITS, follow synopsis order (n…
StephanTLavavej Jul 28, 2020
0355938
Improve comments.
StephanTLavavej Jul 28, 2020
e372f73
Clarify comment.
StephanTLavavej Jul 28, 2020
f906d04
Rename to P1614R2_spaceship.
StephanTLavavej Jul 28, 2020
3ec3965
Comment and formatting changes.
StephanTLavavej Jul 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions stl/inc/vector
Original file line number Diff line number Diff line change
Expand Up @@ -2839,14 +2839,51 @@ _NODISCARD bool operator!=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _
template <class _Ty, class _Alloc>
_NODISCARD _Synth_three_way_result<_Ty> operator<=>(
const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) {
return _STD lexicographical_compare_three_way(_Left._Unchecked_begin(), _Left._Unchecked_end(),
_Right._Unchecked_begin(), _Right._Unchecked_end(), _Synth_three_way{});
if constexpr (is_same_v<_Ty, bool>) {
// This optimization works because vector<bool> "trims" its underlying storage by zeroing out unused bits.
const auto _Min_word_size = (_STD min)(_Left._Myvec.size(), _Right._Myvec.size());
const auto _Left_words = _Left._Myvec._Unchecked_begin();
const auto _Right_words = _Right._Myvec._Unchecked_begin();

const strong_ordering _Word_comparison = _STD lexicographical_compare_three_way( // don't need _Synth_three_way
_Left_words, _Left_words + _Min_word_size, _Right_words, _Right_words + _Min_word_size);

if (_Word_comparison != 0) {
return _Word_comparison;
}

return _Left.size() <=> _Right.size();
} else {
return _STD lexicographical_compare_three_way(_Left._Unchecked_begin(), _Left._Unchecked_end(),
_Right._Unchecked_begin(), _Right._Unchecked_end(), _Synth_three_way{});
}
}
#else // __cpp_lib_concepts
template <class _Ty, class _Alloc>
_NODISCARD bool operator<(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) {
return _STD lexicographical_compare(
_Left._Unchecked_begin(), _Left._Unchecked_end(), _Right._Unchecked_begin(), _Right._Unchecked_end());
#if _HAS_IF_CONSTEXPR
if constexpr (is_same_v<_Ty, bool>) {
// This optimization works because vector<bool> "trims" its underlying storage by zeroing out unused bits.
auto _First = _Left._Myvec._Unchecked_begin();
auto _Other = _Right._Myvec._Unchecked_begin();

const auto _Last = _First + (_STD min)(_Left._Myvec.size(), _Right._Myvec.size());

for (; _First != _Last; ++_First, (void) ++_Other) {
if (*_First < *_Other) {
return true;
} else if (*_First > *_Other) {
return false;
}
}

return _Left.size() < _Right.size();
} else
#endif // _HAS_IF_CONSTEXPR
{
return _STD lexicographical_compare(
_Left._Unchecked_begin(), _Left._Unchecked_end(), _Right._Unchecked_begin(), _Right._Unchecked_end());
}
}

template <class _Ty, class _Alloc>
Expand Down