memchunk: Add noexcept

This commit is contained in:
Tatsuhiro Tsujikawa 2016-01-17 17:16:20 +09:00
parent ef5d981ab1
commit ba543e3895
1 changed files with 12 additions and 7 deletions

View File

@ -89,14 +89,16 @@ template <typename Memchunk> struct Memchunks {
Memchunks(Pool<Memchunk> *pool) Memchunks(Pool<Memchunk> *pool)
: pool(pool), head(nullptr), tail(nullptr), len(0) {} : pool(pool), head(nullptr), tail(nullptr), len(0) {}
Memchunks(const Memchunks &) = delete; Memchunks(const Memchunks &) = delete;
Memchunks(Memchunks &&other) Memchunks(Memchunks &&other) noexcept : pool(other.pool),
: pool(other.pool), head(other.head), tail(other.tail), len(other.len) { head(other.head),
tail(other.tail),
len(other.len) {
// keep other.pool // keep other.pool
other.head = other.tail = nullptr; other.head = other.tail = nullptr;
other.len = 0; other.len = 0;
} }
Memchunks &operator=(const Memchunks &) = delete; Memchunks &operator=(const Memchunks &) = delete;
Memchunks &operator=(Memchunks &&other) { Memchunks &operator=(Memchunks &&other) noexcept {
if (this == &other) { if (this == &other) {
return *this; return *this;
} }
@ -253,14 +255,17 @@ template <typename Memchunk> struct PeekMemchunks {
: memchunks(pool), cur(nullptr), cur_pos(nullptr), cur_last(nullptr), : memchunks(pool), cur(nullptr), cur_pos(nullptr), cur_last(nullptr),
len(0), peeking(true) {} len(0), peeking(true) {}
PeekMemchunks(const PeekMemchunks &) = delete; PeekMemchunks(const PeekMemchunks &) = delete;
PeekMemchunks(PeekMemchunks &&other) PeekMemchunks(PeekMemchunks &&other) noexcept
: memchunks(std::move(other.memchunks)), cur(other.cur), : memchunks(std::move(other.memchunks)),
cur_pos(other.cur_pos), cur_last(other.cur_last), len(other.len), cur(other.cur),
cur_pos(other.cur_pos),
cur_last(other.cur_last),
len(other.len),
peeking(other.peeking) { peeking(other.peeking) {
other.reset(); other.reset();
} }
PeekMemchunks &operator=(const PeekMemchunks &) = delete; PeekMemchunks &operator=(const PeekMemchunks &) = delete;
PeekMemchunks &operator=(PeekMemchunks &&other) { PeekMemchunks &operator=(PeekMemchunks &&other) noexcept {
if (this == &other) { if (this == &other) {
return *this; return *this;
} }