Skip to content

Commit

Permalink
Add noexcept to memorychunk and memoryview move constructor (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
aurianer authored Jun 6, 2023
1 parent 3bc4580 commit 8982e7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/dlaf/memory/memory_chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ class MemoryChunk {
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
/// Move constructor.
MemoryChunk(MemoryChunk&& rhs) : size_(rhs.size_), ptr_(rhs.ptr_), allocated_(rhs.allocated_) {
MemoryChunk(MemoryChunk&& rhs) noexcept
: size_(rhs.size_), ptr_(rhs.ptr_), allocated_(rhs.allocated_) {
rhs.ptr_ = nullptr;
rhs.size_ = 0;
rhs.allocated_ = false;
Expand Down
5 changes: 3 additions & 2 deletions include/dlaf/memory/memory_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <cstdlib>
#include <memory>
#include <utility>

#include "memory_chunk.h"
#include "dlaf/common/assert.h"
Expand Down Expand Up @@ -64,14 +65,14 @@ class MemoryView {
MemoryView(const MemoryView<ElementType, D>& rhs)
: memory_(rhs.memory_), offset_(rhs.offset_), size_(rhs.size_) {}

MemoryView(MemoryView&& rhs)
MemoryView(MemoryView&& rhs) noexcept
: memory_(std::move(rhs.memory_)), offset_(rhs.offset_), size_(rhs.size_) {
rhs.size_ = 0;
rhs.offset_ = 0;
}

template <class U = T, class = typename std::enable_if_t<std::is_const_v<U> && std::is_same_v<T, U>>>
MemoryView(MemoryView<ElementType, D>&& rhs)
MemoryView(MemoryView<ElementType, D>&& rhs) noexcept
: memory_(rhs.memory_), offset_(rhs.offset_), size_(rhs.size_) {
rhs.memory_ = std::make_shared<MemoryChunk<ElementType, D>>();
rhs.size_ = 0;
Expand Down

0 comments on commit 8982e7e

Please sign in to comment.