. Do I need to have a copy constructor available when binding a temporary to a link?
Post C ++ 11 - No
Pre C ++ 11 - Yes.
This code compiles fine with GCC 4.7.2 because it is compatible with the C ++ 11 standard.
The C ++ 11 standard indicates that when initializing a reference to a constant from prvalue it must be bound directly to the reference object, and time resolution is not allowed to be created. In addition, the copy constructor is not used or not required.
Before C ++ 11, the rules were different. And this behavior (the copy constructor will be called) is determined by the implementation. C ++ 03 allowed to call the copy constructor when binding the const link to a temporary one and, therefore, to the C ++ 11 message, the copy constructor should be available. Visual C ++ 2010 adheres to the C ++ 03 standard.
Alok save
source share