This seems to me this discussion exhibits the A/B problem since the begging. For the mailing list, it doesn't sound very clear how how it would be beneficial to add a built-in feature when something which is already builtin the language exits for in place construction (placement new, does not allocate btw). In general. adding a second way to do something is not good unless it help reduce boilerplate and has enough use in *canonical* C++ (code written along the lines of std lib, boost, cppCoreguidelines).

Unless you are working on the design of a conformimg AllocatoAwareContainer, or boxing-like types (std::optional, std::variant, etc) you should never need to touch std::construct_at, std::destroy_at, placement new, explicit dtor calls.

As for your example (txt editor): calling `vector::reserve` and using move semantics. swaps, and in place insertion; to me that seems to solve issues of superficial reallocation.

Note: things like two step init is an antiguideline (at least in c++ way of expressing ideas). The canonical *C++*, has a different approach for this.


From: Greg McPherran via Std-Proposals <std-proposals@lists.isocpp.org>
Sent: August 14, 2022 10:06:36 p.m. EDT
To: "std-proposals@lists.isocpp.org" <std-proposals@lists.isocpp.org>
Cc: Greg McPherran <GMcPherran@WebSoftHost.com>
Subject: Re: [std-proposals] Re-Init Example Use Case

Text editor implemented as a vector of strings. Each string in vector is a line of text.

vector implementation internally leverages re-init by cache'ing the string objects for removed lines of text. When new lines of text are created e.g. by emplacement, the vector can determine whether to construct a new string or re-init an existing string object based on availability of what is in the cache. 

Currently, this would be handled by std::construct_at(...) using an instance rvalue. This is fine for raw empty memory, but for existing instances in the vector purposefully made available for re-use, the "emplace using re-init feature syntax" is simpler and more concise, and incorporates recognition of this pattern into the language. What is std::xyz today may be a prototype for tomorrow's language syntax and I propose that the re-init ctor is an example.

I also maintain that unique_ptr::reset() is a perfectly valid example of usefulness of re-init concept.

Anyway, I've stated my case. And with regards to "tossing" ideas, as I mentioned, if a language designer would like me to further collaborate, I am willing and I already offer the some_object_instance::(ctor_args) syntax suggestion.

Have Great Night All,
Greg McPherran

-- Julien Villemure
Sent from my Android device with K-9 Mail.