_S_noexcept1()
{
if constexpr (is_trivially_default_constructible_v<_Tp>)
- return is_nothrow_assignable_v<_Tp, _Up>;
+ return is_nothrow_assignable_v<_Tp&, _Up>;
else
return is_nothrow_constructible_v<_Tp, _Up>;
}
if (_M_index == 0)
{
if constexpr (is_trivially_default_constructible_v<_It>)
- _M_it = std::move(__x._M_it);
+ _M_it = __x._M_it;
else
std::construct_at(std::__addressof(_M_it), __x._M_it);
}
else if (_M_index == 1)
{
if constexpr (is_trivially_default_constructible_v<_Sent>)
- _M_sent = std::move(__x._M_sent);
+ _M_sent = __x._M_sent;
else
std::construct_at(std::__addressof(_M_sent), __x._M_sent);
}
operator=(const common_iterator<_It2, _Sent2>& __x)
noexcept(is_nothrow_constructible_v<_It, const _It2&>
&& is_nothrow_constructible_v<_Sent, const _Sent2&>
- && is_nothrow_assignable_v<_It, const _It2&>
- && is_nothrow_assignable_v<_Sent, const _Sent2&>)
+ && is_nothrow_assignable_v<_It&, const _It2&>
+ && is_nothrow_assignable_v<_Sent&, const _Sent2&>)
{
switch(_M_index << 2 | __x._M_index)
{
private:
template<input_or_output_iterator _It2, sentinel_for<_It2> _Sent2>
+ requires (!same_as<_It2, _Sent2>) && copyable<_It2>
friend class common_iterator;
constexpr bool _M_has_value() const noexcept { return _M_index < 2; }
using I = std::common_iterator<int*, const int*>;
static_assert( std::is_default_constructible_v<I> );
static_assert( std::is_copy_constructible_v<I> );
+ static_assert( std::is_move_constructible_v<I> );
static_assert( std::is_copy_assignable_v<I> );
+ static_assert( std::is_move_assignable_v<I> );
static_assert( std::is_constructible_v<I, int*> );
static_assert( std::is_constructible_v<I, const int*> );
- struct sentinel { operator int*() const { return nullptr; } };
+ static_assert( std::is_nothrow_copy_constructible_v<I> ); // GCC extension
+ static_assert( std::is_nothrow_move_constructible_v<I> ); // GCC extension
+ static_assert( std::is_nothrow_copy_assignable_v<I> ); // GCC extension
+ static_assert( std::is_nothrow_move_assignable_v<I> ); // GCC extension
+
+ struct sentinel { operator int*() const noexcept { return nullptr; } };
using K = std::common_iterator<int*, sentinel>;
static_assert( std::is_constructible_v<I, const K&> );
static_assert( std::is_assignable_v<I, const K&> );
+ static_assert( std::is_nothrow_assignable_v<I&, const K&> ); // GCC extension
+
+ struct sentinel_throwing { operator int*() const { return nullptr; } };
+ using K_throwing = std::common_iterator<int*, sentinel_throwing>;
+ // Conversion is noexcept(false)
+ static_assert( ! std::is_nothrow_assignable_v<I&, const K_throwing&> );
+
+
struct sentinel2
{
const int* p;
using J = std::common_iterator<const int*, sentinel2>;
static_assert( std::is_constructible_v<J, const I&> );
static_assert( std::is_convertible_v<const I&, J> );
+
+ static_assert( std::is_constructible_v<J, I> );
+ static_assert( std::is_convertible_v<I, J> );
+
+ // Constructor is noexcept(false)
+ static_assert( ! std::is_nothrow_constructible_v<J, I> );
}
void