Using std::vector<DeviceTy> requires implementing copy constructor and copied assign operator for DeviceTy.
Indeed DeviceTy should never be copied. After changing to std::vector<std::unique_ptr<DeviceTy>>,
All the unsafe copy constructor and copy assign operator implementations can be removed.
Compilers mark them deleted due to mutex or underlying objects and this is the desired behavior.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
openmp/libomptarget/src/rtl.cpp | ||
---|---|---|
325 | what about emplace_back? |
openmp/libomptarget/src/rtl.cpp | ||
---|---|---|
325 | Both push_back and emplace_back do the same thing of invoking the move constructor of unique_ptr. However, emplace_back is less verbose in readability. So push_back is preferred here. |
openmp/libomptarget/src/device.h | ||
---|---|---|
279 | Mark them as delete if you expect it should not be copied at all. |
openmp/libomptarget/src/device.h | ||
---|---|---|
279 | Added. It makes the non-copyable nature explicitly expressed. |
Mark them as delete if you expect it should not be copied at all.