This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Jason Merrill wrote:
2) Specify that for some types, initialization is complete when the initialization of each member is complete. Perhaps this could just be for any type with an implicitly defined constructor, or even a user-defined constructor with an empty body?
"User-defined constructor with an empty body" is a logical generalization of trivial constructor, but not one previously in the standard; if we do this here, I think we should do it everywhere.
I guess the naive meta-question (and I am naive, so I will ask it), is why it's desirable that:
pair<X, Y> *p = ::operator new(sizeof(pair<X,Y>)); ::new (&p->first) X(...); ::new (&p->second) Y(...);
be a valid way to create a pair<X, Y>?
I gather what we're trying to do is to avoid the cost of a copy, given we of course cannot design constructors for pair that match the constructors for X and Y, so that the constructor for pair can itself do the construction.
But, can't the compiler already elide the copy if we do:
pair(X(...), Y(...))
?
If not, it seems to me that it would be nicer to extend the language so that we *can* do that, possibly by adding syntax if needs be.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |