Which constructor is better for the following class?
struct Foo
{
Foo(const int& val):val_(val){} // constructor 1
Foo(int val):val_(val){} // constructor 2
int val_;
};
Without any compiler optimization, do they copy val only once or does constructor 2 create a further copy before the initialization list?