From ab0bb60602ef8e4e98cb53f2453e8a4e9a674d76 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 22 May 2019 15:05:00 +1000 Subject: [PATCH] pool: add move constructor --- pool.hpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pool.hpp b/pool.hpp index b863508a..4be5b764 100644 --- a/pool.hpp +++ b/pool.hpp @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * Copyright 2011-2016 Danny Robson + * Copyright 2011-2019 Danny Robson */ #pragma once @@ -50,7 +50,23 @@ namespace cruft { pool (const pool&) = delete; pool& operator= (const pool&) = delete; - pool (pool&&) noexcept; + pool (pool &&rhs) noexcept + : m_head (nullptr) + , m_next (nullptr) + , m_capacity (0) + , m_size (0) + { + std::swap (m_head, rhs.m_head); + + m_next = rhs.m_next.load (); + rhs.m_next = nullptr; + + std::swap (m_capacity, rhs.m_capacity); + + m_size = rhs.m_size.load (); + rhs.m_size = 0; + } + pool& operator= (pool&&); explicit