What is the difference between the two forms of initialization, T obj = {…}
and T obj{…}
?
I initially thought T obj = {…}
was shorthand for T obj = T{…}
where a temporary object is copied into our new object. This, although doesn't execute a copy constructor (copy elision), requires its existence and access to it. But when I blocked copy constructor access in this particular class by making the constructor private, there was no error.
This means that there is no copy mechanism involved. So what's the function of the '=' symbol?
I have referred to the following question but was dissatisfied because of the absence of an explanation:
Is C++11 Uniform Initialization a replacement for the old style syntax?
EDIT: On a similar note, is there a difference between int arr[]{…}
and int arr[] = {…}
? I am asking this to see if I can bring out the contrast between uniform initialization and list initialization.