Consider this snippet:
#include
struct A
{
A(int b): m_b(b) { }
private:
int m_b;
};
int main()
{
std::vector vec;
vec.push_back( A(3) );
vec.emplace_back( 3 );
}
In that particular case where a temporary value is passed, is there any difference between the 2 calls that a compiler won’t optimize away? Should I prefer one to the other?
No comments:
Post a Comment