STL icon indicating copy to clipboard operation
STL copied to clipboard

`<expected>`: Add deleted function overloads to `expected`

Open frederick-vs-ja opened this issue 1 year ago • 1 comments
trafficstars

Currently,

  • libc++'s expected has all deleted overloads specified in the standard, including the inconsistent deleted overload of move assignment operator.
  • libstdc++'s expected seems to have all but the inconsistent one (the defaulted overloads are sometimes deleted).
  • MSVC STL's expected lacks deleted overloads (including those of copy constructors). My recent PR #4271 doesn't change this.

Given that the standard generally doesn't make move functions conditionally deleted, I tried to submit an LWG issue to constrain the move assignment operator of expected<cv void, E>. Edit: this is now LWG-4025.

It seems that the existence of deleted overloads can affect overload resolution in some corner cases, e.g. when someone uses a class derived from expected with using expected::operator=;. On the other hand, we can properly constrain copy functions since C++20, so it's doubtful whether expected should have deleted overloads.

frederick-vs-ja avatar Dec 19 '23 01:12 frederick-vs-ja

We talked about this at the weekly maintainer meeting and we believe that we should Do What The Standard Says(TM) here, except when the Standard depicts deleted move operations (@CaseyCarter strongly believes that the Standard is bogus whenever it depicts that).

StephanTLavavej avatar Jan 10 '24 22:01 StephanTLavavej