Skip to content

Use std::byte for in-place object construction #98

@mingxwa

Description

@mingxwa

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions