Is there a difference between copy initialization and direct initialization?

Suppose I have this function:

void my_test()
{
    A a1 = A_factory_func();
    A a2(A_factory_func());

    double b1 = 0.5;
    double b2(0.5);

    A c1;
    A c2 = A();
    A c3(A());
}

In each grouping, are these statements identical? Or is there an extra (possibly optimizable) copy in some of the initializations?

I have seen people say both things. Please cite text as proof. Also add other cases please.

9 Answers
9

Leave a Comment