Created on 2020-11-18.00:00:00 last changed 1 month ago
[ 2020-11-29; Reflector prioritization ]
Set priority to 2 during reflector discussions.
This compiles but the resulting view is full of dangling references:
std::vector<int> vec = {42}; auto r = vec | std::views::transform([](auto c) { return std::make_tuple(c, c); }) | std::views::keys;
This is because elements_view::iterator::operator* is specified as
constexpr decltype(auto) operator*() const { return get<N>(*current_); }
Here *current_ is a prvalue, and so the get<N> produces a reference into the materialized temporary that becomes dangling as soon as operator* returns.
We should either ban this case altogether, or make operator* (and operator[]) return by value when *current_ is a prvalue and the corresponding tuple element is not a reference (since this get is std::get, we need not worry about weird user-defined overloads.)History | |||
---|---|---|---|
Date | User | Action | Args |
2020-11-29 14:06:26 | admin | set | messages: + msg11637 |
2020-11-18 00:00:00 | admin | create |