@@ -54,15 +54,27 @@ namespace STDEXEC
5454
5555 template <class _Ty , std::size_t _Capacity0, std::size_t _Capacity1>
5656 [[nodiscard]]
57- friend constexpr auto operator +(__static_vector<_Ty, _Capacity0> const &__lhs, //
58- __static_vector<_Ty, _Capacity1> const &__rhs)
57+ friend constexpr auto
58+ operator +([[maybe_unused]] __static_vector<_Ty, _Capacity0> const &__lhs, //
59+ [[maybe_unused]] __static_vector<_Ty, _Capacity1> const &__rhs)
5960 noexcept (__nothrow_copy_constructible<_Ty>) -> __static_vector<_Ty, _Capacity0 + _Capacity1>
6061 {
61- __static_vector<_Ty, _Capacity0 + _Capacity1> __result;
62- std::copy (__lhs.begin (), __lhs.end (), __result.begin ());
63- std::copy (__rhs.begin (), __rhs.end (), __result.begin () + __lhs.size ());
64- __result.resize (__lhs.size () + __rhs.size ());
65- return __result;
62+ if constexpr (_Capacity0 == 0 )
63+ {
64+ return __rhs;
65+ }
66+ else if constexpr (_Capacity1 == 0 )
67+ {
68+ return __lhs;
69+ }
70+ else
71+ {
72+ __static_vector<_Ty, _Capacity0 + _Capacity1> __result;
73+ std::copy (__lhs.begin (), __lhs.end (), __result.begin ());
74+ std::copy (__rhs.begin (), __rhs.end (), __result.begin () + __lhs.size ());
75+ __result.resize (__lhs.size () + __rhs.size ());
76+ return __result;
77+ }
6678 }
6779 };
6880 } // namespace __detail
@@ -134,13 +146,19 @@ namespace STDEXEC
134146
135147 constexpr void resize (std::size_t __new_size) noexcept
136148 {
149+ STDEXEC_ASSERT (__new_size <= _Capacity);
137150 __size_ = __new_size;
138151 }
139152
140153 constexpr auto erase (const_iterator __first, const_iterator __last) noexcept -> iterator
141154 {
142- std::move (const_cast <iterator>(__last), end (), const_cast <iterator>(__first));
143- resize (size () - (__last - __first));
155+ STDEXEC_ASSERT (__first >= begin () && __first <= end ());
156+ STDEXEC_ASSERT (__last >= __first && __last <= end ());
157+ if (__first != __last)
158+ {
159+ std::move (const_cast <iterator>(__last), end (), const_cast <iterator>(__first));
160+ resize (size () - (__last - __first));
161+ }
144162 return end ();
145163 }
146164
@@ -207,11 +225,15 @@ namespace STDEXEC
207225 return 0 ;
208226 }
209227
210- constexpr auto erase (const_iterator __first, const_iterator __last ) noexcept -> iterator
228+ constexpr void resize ( [[maybe_unused]] std:: size_t __new_size ) noexcept
211229 {
212- STDEXEC_ASSERT (__first == __last );
213- STDEXEC_ASSERT (__first == nullptr );
230+ STDEXEC_ASSERT (__new_size == 0 );
231+ }
214232
233+ constexpr auto erase ([[maybe_unused]] const_iterator __first,
234+ [[maybe_unused]] const_iterator __last) noexcept -> iterator
235+ {
236+ STDEXEC_ASSERT (__first == __last);
215237 return end ();
216238 }
217239 };
0 commit comments