Skip to content

Commit ac5c334

Browse files
committed
Make copy/move ctors and assignment operators default
Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 46f0991 commit ac5c334

File tree

2 files changed

+10
-39
lines changed

2 files changed

+10
-39
lines changed

sycl/include/sycl/ext/oneapi/weak_object.hpp

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,15 @@ class weak_object : public detail::weak_object_base<SYCLObjT> {
4242
constexpr weak_object() noexcept : detail::weak_object_base<SYCLObjT>() {}
4343
weak_object(const SYCLObjT &SYCLObj) noexcept
4444
: detail::weak_object_base<SYCLObjT>(SYCLObj) {}
45-
weak_object(const weak_object &Other) noexcept
46-
: detail::weak_object_base<SYCLObjT>(Other) {}
47-
weak_object(weak_object &&Other) noexcept
48-
: detail::weak_object_base<SYCLObjT>(Other) {}
45+
weak_object(const weak_object &Other) noexcept = default;
46+
weak_object(weak_object &&Other) noexcept = default;
4947

5048
weak_object &operator=(const SYCLObjT &SYCLObj) noexcept {
5149
this->MObjWeakPtr = sycl::detail::getSyclObjImpl(SYCLObj);
5250
return *this;
5351
}
54-
weak_object &operator=(const weak_object &Other) noexcept {
55-
this->MObjWeakPtr = Other.MObjWeakPtr;
56-
return *this;
57-
}
58-
weak_object &operator=(weak_object &&Other) noexcept {
59-
this->MObjWeakPtr = std::move(Other.MObjWeakPtr);
60-
return *this;
61-
}
52+
weak_object &operator=(const weak_object &Other) noexcept = default;
53+
weak_object &operator=(weak_object &&Other) noexcept = default;
6254

6355
std::optional<SYCLObjT> try_lock() const noexcept {
6456
auto MObjImplPtr = this->MObjWeakPtr.lock();
@@ -95,15 +87,8 @@ class weak_object<buffer<T, Dimensions, AllocatorT>>
9587
: detail::weak_object_base<buffer_type>(SYCLObj), MRange{SYCLObj.Range},
9688
MOffsetInBytes{SYCLObj.OffsetInBytes},
9789
MIsSubBuffer{SYCLObj.IsSubBuffer} {}
98-
weak_object(const weak_object &Other) noexcept
99-
: detail::weak_object_base<buffer_type>(Other), MRange{Other.MRange},
100-
MOffsetInBytes{Other.MOffsetInBytes}, MIsSubBuffer{Other.MIsSubBuffer} {
101-
}
102-
weak_object(weak_object &&Other) noexcept
103-
: detail::weak_object_base<buffer_type>(Other),
104-
MRange{std::move(Other.MRange)},
105-
MOffsetInBytes{std::move(Other.MOffsetInBytes)},
106-
MIsSubBuffer{std::move(Other.MIsSubBuffer)} {}
90+
weak_object(const weak_object &Other) noexcept = default;
91+
weak_object(weak_object &&Other) noexcept = default;
10792

10893
weak_object &operator=(const buffer_type &SYCLObj) noexcept {
10994
this->MObjWeakPtr = sycl::detail::getSyclObjImpl(SYCLObj);
@@ -112,20 +97,8 @@ class weak_object<buffer<T, Dimensions, AllocatorT>>
11297
this->MIsSubBuffer = SYCLObj.IsSubBuffer;
11398
return *this;
11499
}
115-
weak_object &operator=(const weak_object &Other) noexcept {
116-
this->MObjWeakPtr = Other.MObjWeakPtr;
117-
this->MRange = Other.MRange;
118-
this->MOffsetInBytes = Other.MOffsetInBytes;
119-
this->MIsSubBuffer = Other.MIsSubBuffer;
120-
return *this;
121-
}
122-
weak_object &operator=(weak_object &&Other) noexcept {
123-
this->MObjWeakPtr = std::move(Other.MObjWeakPtr);
124-
this->MRange = std::move(Other.MRange);
125-
this->MOffsetInBytes = std::move(Other.MOffsetInBytes);
126-
this->MIsSubBuffer = std::move(Other.MIsSubBuffer);
127-
return *this;
128-
}
100+
weak_object &operator=(const weak_object &Other) noexcept = default;
101+
weak_object &operator=(weak_object &&Other) noexcept = default;
129102

130103
std::optional<buffer_type> try_lock() const noexcept {
131104
auto MObjImplPtr = this->MObjWeakPtr.lock();

sycl/include/sycl/ext/oneapi/weak_object_base.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ template <typename SYCLObjT> class weak_object_base {
3232
constexpr weak_object_base() noexcept : MObjWeakPtr() {}
3333
weak_object_base(const SYCLObjT &SYCLObj) noexcept
3434
: MObjWeakPtr(sycl::detail::getSyclObjImpl(SYCLObj)) {}
35-
weak_object_base(const weak_object_base &Other) noexcept
36-
: MObjWeakPtr(Other.MObjWeakPtr) {}
37-
weak_object_base(weak_object_base &&Other) noexcept
38-
: MObjWeakPtr(std::move(Other.MObjWeakPtr)) {}
35+
weak_object_base(const weak_object_base &Other) noexcept = default;
36+
weak_object_base(weak_object_base &&Other) noexcept = default;
3937

4038
void reset() noexcept { MObjWeakPtr.reset(); }
4139
void swap(weak_object_base &Other) noexcept {

0 commit comments

Comments
 (0)