←back to thread

178 points todsacerdoti | 2 comments | | HN request time: 1.201s | source
Show context
xKingfisher ◴[] No.26340389[source]
Not to mention the very real risk of accidently invoking the wrong constructor. If you change the type of a vector, push_back is a good deal safer than emplace_back.

Especially since many of the standard containers have many more constructors that you'd think - hello std::vector(size_type count).

replies(2): >>26340429 #>>26340594 #
1. codeflo ◴[] No.26340594[source]
That’s one of my favorites as well. The fact that C++ will so happily auto-convert almost anything into an integer makes it even more likely to hit this accidentally.
replies(1): >>26340755 #
2. xKingfisher ◴[] No.26340755[source]
And explicit constructors won't save you from this one.