Use `std::byte` for in-place object construction
mingxwa opened this issue · comments
The implementation of class template proxy
currently uses char arrays for in-place object construction. While functional, accessing the underlying object leads to UB. We propose changing the element type to std::byte
for improved readability and alignment with C++ standards.
According to @frederick-vs-ja:
Such in-place-new ends the lifetime of the enclosing complete object and the nested objects that overlap with the newly created object due to [basic.life]/1.5. And then any further non-static member function invocation, including destruction, on such an enclosing object (e.g. a
proxy
object) will be UB as per [basic.life]/6.2 and /7.2.