Date: Fri, 17 Nov 2023 10:40:02 +0000
On Fri, 17 Nov 2023 at 08:50, Ghevond Gevorgyan via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Hi Giuseppe,
>
> Thank you for your explanation.
>
> I cannot provide a specific use case for it, but my point is that there is
> a definition like this:
>
> init-statementopt auto &&range = for-range-initializer;
>
> and then there are `range.begin()` / `range.end()` calls which ignore the
> value category of the expression. This seemed weird to me. I think if there
> were a single function to get `begin()` and `end()` like this:
> std::pair<Iter, Iter> begin_end() &&; it would be okay.
>
> Also worth noting is that the use-after-move has some well-defined
> behaviors in the standard, for example
>
> *unique_ptr(unique_ptr&& u) noexcept;*
> - *Postconditions*: get() yields the value u.get() yielded before the
> construction. *u.get() == nullptr*. get_deleter() returns a
> reference to the stored deleter that was constructed from u.get_deleter(). *If
> D is a reference type then get_deleter() and u.get_deleter() both reference
> the same lvalue deleter.*
>
> and this means that there can be some special cases.
>
use-after-move is not UB for types defined in the standard. Guiseppe can
have different rules for his own classes though.
std-proposals_at_[hidden]> wrote:
> Hi Giuseppe,
>
> Thank you for your explanation.
>
> I cannot provide a specific use case for it, but my point is that there is
> a definition like this:
>
> init-statementopt auto &&range = for-range-initializer;
>
> and then there are `range.begin()` / `range.end()` calls which ignore the
> value category of the expression. This seemed weird to me. I think if there
> were a single function to get `begin()` and `end()` like this:
> std::pair<Iter, Iter> begin_end() &&; it would be okay.
>
> Also worth noting is that the use-after-move has some well-defined
> behaviors in the standard, for example
>
> *unique_ptr(unique_ptr&& u) noexcept;*
> - *Postconditions*: get() yields the value u.get() yielded before the
> construction. *u.get() == nullptr*. get_deleter() returns a
> reference to the stored deleter that was constructed from u.get_deleter(). *If
> D is a reference type then get_deleter() and u.get_deleter() both reference
> the same lvalue deleter.*
>
> and this means that there can be some special cases.
>
use-after-move is not UB for types defined in the standard. Guiseppe can
have different rules for his own classes though.
Received on 2023-11-17 10:40:17