+ 1

Assign nullptr to weak_ptr

Please refer below code: https://code.sololearn.com/cdClM60XB7Eg/?ref=app As expected, it does not release memory of nodes still being smart pointer. Shared pointer is used and it is double linked list so cyclic reference is used and obviously need weak pointer. I belive weak_ptr can't be allocated as nullptr. If so, how can I compare to verify that List end has been reached.?

21st Jun 2021, 11:29 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 Réponse
+ 1
Yeah I can use it directly but this excercise is not for any requirement... it is purely for learning and making concept clear... There are hell lot of you Tuber and sights which teach how to implement linked list using raw pointer (that too without deleting and not doing memory management). I thought to do it using smart pointer and got stuck so curious to do it now
21st Jun 2021, 1:38 PM
Ketan Lalcheta
Ketan Lalcheta - avatar