On Thu, Aug 13, 2020 at 9:58 AM Arthur O'Dwyer via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
To implement `iterator_to` for anything except `vector`, you have to rely on a cast like this:

struct Node {
    T t;
    Node *next;
};
Node *node_from_t(T *t) {
    return reinterpret_cast<Node *>(t);
}
int main() {
    Node n;
    assert(node_from_t(&n.t) == &n);
}

I'm not sure if this is well-defined. As long as `t` is the first member of `Node`, I think it might actually be well-defined; but I wouldn't bet money on it.
Problem is, library implementors tend to be extremely loath to rely on anything smelling of UB in their implementations.

my $.02,
–Arthur

This is well-defined. A pointer to the first non-static data member of a struct is pointer-convertible with a pointer to the struct.

Also there's plenty of UB in standard library container implementations. Very difficult to implement stuff like extract() otherwise.

Barry