Title
basic_const_iterator doesn't work with optional
Status
new
Section
[const.iterators]
Submitter
Hewill Kang

Created on 2023-08-26.00:00:00 last changed 13 months ago

Messages

Date: 2023-10-15.00:00:00

[ 2023-10-30; Reflector poll ]

Set priority to 3 after reflector poll.

Date: 2023-08-26.00:00:00

The heterogeneous comparison operators of basic_const_iterator only constrain type I to be comparable with the underlying iterator type, which allows non-iterator types such as optional, and the heterogeneous comparison operators of the latter would make the situation worse (demo):

#include <iterator>
#include <optional>
  
int main() {
  std::basic_const_iterator<const int*> it;
  std::optional opt{it};
  auto c = opt < it; // infinite meta-recursion
  auto d = it - opt; // infinite meta-recursion
}
History
Date User Action Args
2023-10-30 17:22:20adminsetmessages: + msg13794
2023-08-26 00:00:00admincreate