Skip to content
Snippets Groups Projects
Unverified Commit 70576ca5 authored by thorstenhater's avatar thorstenhater Committed by GitHub
Browse files

Fix issues found in device_coordinator.hpp. (#1086)

* Check for self-assignment in `device_reference::operator=(const device_reference&)`.
* Return reference to self in ` device_reference::operator=(const device_reference&)`.
* Prohibit default construction of `device_reference` and clarify copy semantics.
parent 1be81105
No related branches found
No related tags found
No related merge requests found
......@@ -80,10 +80,19 @@ public:
return *this;
}
// Assigning to a reference will copy the referenced memory
device_reference& operator=(const device_reference& ref) {
gpu_memcpy_d2d(pointer_, ref.pointer_, sizeof(T));
if (this != &ref) {
gpu_memcpy_d2d(pointer_, ref.pointer_, sizeof(T));
}
return *this;
}
// No empty references
device_reference() = delete;
// Copying a reference is a shallow copy
device_reference(const device_reference& ref) = default;
operator T() const {
T tmp;
gpu_memcpy_d2h(&tmp, pointer_, sizeof(T));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment