Here is the class with verbose constructors:
class A
{
public:
A() : _a(-1) { std::cerr << "ctor" << _a << std::endl; }
A(int a_) : _a(a_) { std::cerr << "ctor2 "<< _a << std::endl; }
~A() { std::cerr << "dtor "<< _a << std::endl; }
A(const A&) { std::cerr << "cctor "<< _a << std::endl;}
A(A &&) { std::cerr <<"mctor " << _a << std::endl; }
private:
int _a;
};
Why only one constructor is callet in this example:
int main(int,char **)
{
A a(A(1));
}
No move nor copy constructor is called. Is it auto-optimized by the compiler?