Date: 2025-04-24
Audience: Library Evolution Working Group (LEWG), Evolution Working Group (EWG)
Reply-to: Elazar Gershuni [email protected]
Author: Elazar Gershuni (Technion)
This proposal introduces a standardized, opt-in library mechanism in C++ for constructing an object of type T directly into a moved-from state. It provides a free function template moved_from() that invokes a static factory method T::moved_from() defined by the type author, constrained by a concept SupportsMovedFrom. This facility aims to address performance issues and the use of unsafe workarounds in scenarios where an object is constructed solely to be immediately overwritten via assignment or mutation, leveraging the valid but unspecified nature of the moved-from state, while providing a stronger guarantee for optimization.