HomePhorge

Changed bot concerns all classes exclusively use std::unique_ptr and "moved"…

Referenced Files
None
Subscribers

Description

Changed bot concerns all classes exclusively use std::unique_ptr and "moved" the static_assert's (I commented them where they where)

Details

Provenance
DanielAuthored on May 31 2019, 10:46 AM
dschnoellPushed on May 31 2019, 10:51 AM
Parents
R20:c8fee06db9c1: a bit more cleanup
Branches
Unknown
Tags
Unknown

Event Timeline

Daniel <daniel.schnoell@tuwien.ac.at> committed R20:4f72bb7aa735: Changed bot concerns all classes exclusively use std::unique_ptr and "moved"… (authored by Daniel <daniel.schnoell@tuwien.ac.at>).May 31 2019, 10:46 AM

Some suggestions about using unique_ptr...

/include/rosa/agent/CrossReliability.h
130

When you take ownership of the pointer, either by release() like here or by moving the unique_ptr like in reliabilities, it would be better to take the parameter with move semantics (i.e., std::unique_ptr<Abstraction> &&Function) for the signature to indicate that the passed unique_ptr will not be usable after calling this function.

131

I would like to advocate the use of unique_ptr instead of a raw pointer.
It does not change the syntax you use the pointer with and there is no runtime overhead in dereferencing the pointer. Moreover, a smart pointer takes care of deleting the owned object automatically.

I can see that the objects that are owned by raw pointers are deleted in the destructor properly. But should you use smart pointers instead, there would be no need to write a line of destructor as everything would be taken care of automatically when deleting the member fields.