-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Description
The problem is with CommonReference<reference_t<I>, value_type_t<I>&>(). Imagine an iterator I such that reference_t<I> is std::unique_ptr<int>. The CommonReference first computes the common reference type to be std::unique_ptr<int>, then it tests that std::unique_ptr<int>& is ConvertibleTo std::unique_ptr<int>, which is of course false.
The fix is to instead be testing CommonReference<reference_t<I>&&, value_type_t<I>&>(). That causes the common reference to be computed as const std::unique_ptr<int>&, and std::unique_ptr<int>& is indeed convertible to that.
Proposed Resolution
(Includes the resolution for #339, accepted by LWG in Kona but not yet moved in full committee).
Change the Readable concept [iterators.readable] as follows:
template <class I>
concept bool Readable() {
return requires {
typename value_type_t<I>;
typename reference_t<I>;
typename rvalue_reference_t<I>;
} &&
- CommonReference<reference_t<I>, value_type_t<I>&>() &&
- CommonReference<reference_t<I>, rvalue_reference_t<I>>() &&
- CommonReference<rvalue_reference_t<I>, const value_type_t<I>&>();
+ CommonReference<reference_t<I>&&, value_type_t<I>&>() &&
+ CommonReference<reference_t<I>&&, rvalue_reference_t<I>&&>() &&
+ CommonReference<rvalue_reference_t<I>&&, const value_type_t<I>&>();
}CaseyCarter and ckwastra