C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Thu, 30 May 2024 22:52:24 +0000
> Why would we create a new interface for invocation, and then add it to each and every container type, duplicating each and every API which defers responsibility for construction, when the language gives us a mechanism (this one) that works just fine for the purpose?

I disagree, there's no such mechanism.
What you have is an emplace that forwards arguments to a constructor. What this does is to take advantage of a hole in the template metaprogramming to forward an object that is not one that is accepted by the constructor. It then tricks the language to issue a cast (that happens implicitly) instead which in this case invokes a custom function. But this hackery doesn't work completely, because if the constructor is templated it will just accept the object without trying to cast it, cocking it up.
And because it is cocked up, he now wants to add an exception to the core language, so that templates stop working for this special class in order to cover the cock up.



> Note that there's no difference between deferring construction and using the proposed std::elide, and constructing the class directly.

And if that's the case that begs the question as to why you would to use it in the first place?
This is a very good question, why would you use it in the first place?
Every way that is possible to construct the object, you can do it using emplace. So why do you need it?
Why should I accept this wart?


Received on 2024-05-30 22:52:29