-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Choosing reference over pointer #314
Labels
Comments
I tend to agree. Thanks for writing that up @shakthi-prashanth-m. Do you agree @JonasVautherin? |
Yes, I agree. I usually use references and smart pointers instead of raw pointers. |
shakthi-prashanth-m
pushed a commit
that referenced
this issue
Mar 13, 2018
Replace `Device *PluginImplBase::parent` => `Device &PluginImplBase::parent`. And replaces everywhere as required.
shakthi-prashanth-m
pushed a commit
that referenced
this issue
Mar 13, 2018
Replaced wherever applicabale.
shakthi-prashanth-m
pushed a commit
that referenced
this issue
Mar 13, 2018
Smart pointers provide automatic resource management. In other words, they implement "Resource Acquisition Is Initialialization programming idiom". The main goal of this idiom is to ensure that resource acquisition occurs at the same time that the object is initialized, so that all resources for the object are created and made ready in one line of code. `std::unique_ptr` is a smart pointer that owns and manages another object through a pointer and disposes of that object when the unique_ptr goes out of scope. Ref 1: https://docs.microsoft.com/en-us/cpp/cpp/smart-pointers-modern-cpp Ref 2: http://en.cppreference.com/w/cpp/memory/unique_ptr
shakthi-prashanth-m
pushed a commit
that referenced
this issue
Mar 13, 2018
In `CMakeLists.txt`, include directory for example.h is added.
shakthi-prashanth-m
pushed a commit
that referenced
this issue
Mar 13, 2018
This replaces raw pointers used in connections and devices by smart pointers. This avoids, freeing them in destructor and also makes code clean and readable.
shakthi-prashanth-m
pushed a commit
that referenced
this issue
Mar 13, 2018
Updates all the plugin API description about passing device object, instead of pointer to it.
JonasVautherin
pushed a commit
that referenced
this issue
Mar 14, 2018
Replace `Device *PluginImplBase::parent` => `Device &PluginImplBase::parent`. And replaces everywhere as required.
JonasVautherin
pushed a commit
that referenced
this issue
Mar 14, 2018
Replaced wherever applicabale.
JonasVautherin
pushed a commit
that referenced
this issue
Mar 14, 2018
Smart pointers provide automatic resource management. In other words, they implement "Resource Acquisition Is Initialialization programming idiom". The main goal of this idiom is to ensure that resource acquisition occurs at the same time that the object is initialized, so that all resources for the object are created and made ready in one line of code. `std::unique_ptr` is a smart pointer that owns and manages another object through a pointer and disposes of that object when the unique_ptr goes out of scope. Ref 1: https://docs.microsoft.com/en-us/cpp/cpp/smart-pointers-modern-cpp Ref 2: http://en.cppreference.com/w/cpp/memory/unique_ptr
JonasVautherin
pushed a commit
that referenced
this issue
Mar 14, 2018
In `CMakeLists.txt`, include directory for example.h is added.
JonasVautherin
pushed a commit
that referenced
this issue
Mar 14, 2018
This replaces raw pointers used in connections and devices by smart pointers. This avoids, freeing them in destructor and also makes code clean and readable.
JonasVautherin
pushed a commit
that referenced
this issue
Mar 14, 2018
Updates all the plugin API description about passing device object, instead of pointer to it.
JonasVautherin
added a commit
that referenced
this issue
Mar 14, 2018
JonasVautherin
added a commit
that referenced
this issue
Mar 15, 2018
rt-2pm2
pushed a commit
to rt-2pm2/DronecodeSDK
that referenced
this issue
Nov 27, 2018
Replace `Device *PluginImplBase::parent` => `Device &PluginImplBase::parent`. And replaces everywhere as required.
rt-2pm2
pushed a commit
to rt-2pm2/DronecodeSDK
that referenced
this issue
Nov 27, 2018
Replaced wherever applicabale.
rt-2pm2
pushed a commit
to rt-2pm2/DronecodeSDK
that referenced
this issue
Nov 27, 2018
Smart pointers provide automatic resource management. In other words, they implement "Resource Acquisition Is Initialialization programming idiom". The main goal of this idiom is to ensure that resource acquisition occurs at the same time that the object is initialized, so that all resources for the object are created and made ready in one line of code. `std::unique_ptr` is a smart pointer that owns and manages another object through a pointer and disposes of that object when the unique_ptr goes out of scope. Ref 1: https://docs.microsoft.com/en-us/cpp/cpp/smart-pointers-modern-cpp Ref 2: http://en.cppreference.com/w/cpp/memory/unique_ptr
rt-2pm2
pushed a commit
to rt-2pm2/DronecodeSDK
that referenced
this issue
Nov 27, 2018
In `CMakeLists.txt`, include directory for example.h is added.
rt-2pm2
pushed a commit
to rt-2pm2/DronecodeSDK
that referenced
this issue
Nov 27, 2018
This replaces raw pointers used in connections and devices by smart pointers. This avoids, freeing them in destructor and also makes code clean and readable.
rt-2pm2
pushed a commit
to rt-2pm2/DronecodeSDK
that referenced
this issue
Nov 27, 2018
Updates all the plugin API description about passing device object, instead of pointer to it.
rt-2pm2
pushed a commit
to rt-2pm2/DronecodeSDK
that referenced
this issue
Nov 27, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is recommended to use references when we can, and pointers when we have to.
(Reference: https://isocpp.org/wiki/faq/references#refs-vs-ptrs)
We can replace
Device *_parent
toDevice & _parent
as I see that, its possible. We initialize while activating plugin and never modify it. Also, we have a method (below) that actually gives, a reference to a device, not pointer.Consider, below piece of application code:
I just noticed this.
@julianoes, was it done intentionally for some vital reason? If not, then we can find similar usages and replace them properly.
The text was updated successfully, but these errors were encountered: