Talk:cpp/utility/optional/or else
From cppreference.com
Does somebody understand why or_else does not have the non-const lvalue and const rvalue overloads like and_then and transform do?
I see that these overloads were removed from the proposal between version r4 and r5 but I do not understand the rationale.
194.39.218.10 05:37, 16 November 2021 (PST)
and_thenandtransformboth pass the contained value to the invoked function, so the function needs to be given the value with correct cv-qualification.or_elsejust calls the nullary generator function, no cv-qualification is in question, just enough to know whether the return value should be copied or moved in the case of the optional being non-empty --Ybab321 (talk) 07:40, 16 November 2021 (PST)
- Thanks for the explanation. 194.39.218.10 06:27, 17 November 2021 (PST)