Date: Fri, 26 Jan 2024 11:02:44 +0100
Hi Franklin,
could you please elaborate a bit more?
Objects with automatic storage duration are normally constructed at the beginning of the scope. The constinit would (at least potentially) happen during compile-time instead?
One would not know how many copies of those objects are needed one after another (several runs of this scope) or at the same time (recursive function calls into that scope or multiple threads). Would this be internally handled by copying the contents of the compile-time initialized master object. Would that be limited to trivially copyable types or to all types with a copy constructor? That approach would be suboptimal for those scoped variables, which are used only once after all.
Sebastian
-----Ursprüngliche Nachricht-----
Von:Franklin Yang via Std-Proposals <std-proposals_at_[hidden]>
Gesendet:Fr 26.01.2024 10:42
Betreff:[std-proposals] Expanding constinit
An:Std-Proposals_at_[hidden];
CC:yang.franklin9_at_[hidden];
Hello all,
Currently, constinit can only apply to static or thread storage duration. I propose it should also be applicable to automatic storage duration.
Furthermore, const member variables of constinit objects will be constant expressions (which would also make getter functions of these members constant).
These changes should be beneficial in ensuring that construction has no runtime overhead, and could potentially also open up new possibilities with non-static constexpr fields.
Any thoughts?
Best Regards,
Franklin Yang
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2024-01-26 10:02:45