/top/
/new/
/best/
/ask/
/show/
/job/
^
slacker news
login
about
←back to thread
Don’t blindly prefer emplace_back to push_back
(quuxplusone.github.io)
178 points
todsacerdoti
| 1 comments |
04 Mar 21 08:02 UTC
|
HN request time: 0.214s
|
source
Show context
rq1
◴[
04 Mar 21 09:30 UTC
]
No.
26340401
[source]
▶
>>26339893 (OP)
#
widgets.emplace_back(foo, bar, baz);
I honestly always thought that was the only way to use emplace_back.
replies(1):
>>26340815
#
rocqua
◴[
04 Mar 21 10:35 UTC
]
No.
26340815
[source]
▶
>>26340401
#
I mean, if a copy constructor exists then the other version should obviously also work. But at the same time, it isn't quite how this was meant to be used.
replies(1):
>>26341559
#
1.
rq1
◴[
04 Mar 21 12:38 UTC
]
No.
26341559
[source]
▶
>>26340815
#
Yup indeed. :)
ID:
GO
↑