|
|
|
|
|
by gpderetta
544 days ago
|
|
All those naked 'new's in the example make me nervous. I see that the library uses exceptions, if one of the widget constructor throws while composing the overall widget hierarchy, it would leak memory. You should be able to make it work with a value-based interface and allocating behind the scenes (this would also enable a few optimization opportunities). |
|
An alternative approach is to use the rcnew macro, which wraps a pointer in a shared_ptr under the hood. Details on the implementation of rcnew can be found at: https://www.kfr.dev/blog/three-cpp-tricks/