Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Default
Const Copy
Call 1
Destroy
Кстати, в gcc есть ещё похожая оптимизация, связанная с возвращаемым из функции значением.Вы про Return Value Optimization (RVO)? Согласно Вики, эта оптимизация не только в gcc есть, но и в большинстве других компиляторов.
В случае, если выставить это слово перед copy-конструктором, мы получим достаточно забавный запрет неявного приведения типа — запрет приведения к своему типу.
Что ещё забавнее, из-за особенностей синтаксиса С++ вот так: TestClass theTestObject(TestClass()) записать тоже не выйдет, ведь это будет считаться объявлением указателя на функцию и вызовет ошибку:
template<typename T_OtherType,
typename T_OtherHolding,
typename T_OtherAccess>
DReference(
const DReference<T_OtherType, T_OtherHolding, T_OtherAccess> &
inLReference) : _holder(NULL), _holding(), _access()
{
retain(inLReference._holder);
}
A member function template is never instantiated to perform the copy of a class object to an object of its class type.
106) Because a template constructor is never a copy constructor, the presence of such a template does not suppress the implicit declaration of a copy constructor. Template constructors participate in overload resolution with other constructors, including copy constructors, and a template constructor may be used to copy an object if it provides a better match than other constructors.
A member function template is never instantiated to produce such a constructor signature.
(Без)опасный copy elision