Opened 4 years ago

Closed 4 years ago

#572 closed ожидается проверка (задача сдана)

WW_09

Reported by: Jura Khudyakov Owned by: Sokolov Viacheslav
Component: WW shared_ptr Version: 1.0
Keywords: Cc:

Description

Есть 2 финальных коммита: 2294 и 2296
В 2294 всё корректно работает
Но в 2296 исправлено дублирование кода при реализации конструктора и reset-а. Правда, коммит сделан чуть-чуть позже дедлайна, так что оценивать его или 2294, который сделан до дедлайна, - решать вам

Change History (1)

comment:1 Changed 4 years ago by Sokolov Viacheslav

Resolution: задача сдана
Status: assignedclosed

смотрю 2294

8 if (obj != nullptr)
9 {

10 storage_ = new shared_ptr::Storage(obj);
11 }
12 else
13 storage_ = nullptr;

стиль - по-разному определен scope

27 if (this != &other)

здесь не может быть this == &other, в языке нет способа достичь такой ситуации

Самостоятельно звать деструктор (почти) никогда не нужно.

A destructor is a special member function that is called when the lifetime of an object ends. The purpose of the destructor is to free the resources that the object may have acquired during its lifetime.

lifetime у экземпляра точно не закончился внутри метода класса

Единственный случай, когда это необходимо: https://isocpp.org/wiki/faq/dtors#placement-new
Правда, я сходу не смог найти, является ли повторный вызов деструктора UB или нет; пишут только

Note that calling a destructor directly for an ordinary object, such as a local variable, invokes undefined behavior when the destructor is called again, at the end of scope.

Контрактов больше:

  • различные ограничения на ref_count_ во время работы со Storage
  • Storage ожидает not null Matrix* в конструкторе
  • not null в operator -> (как работает x-> ?)
Note: See TracTickets for help on using tickets.