From 4764698069be4e2c10864bb3a26faf6ba7b1f5a1 Mon Sep 17 00:00:00 2001 From: Jason Newton Date: Fri, 2 Sep 2016 17:11:30 -0400 Subject: [PATCH] add move ctor and move-assignment operator --- include/pybind11/common.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/pybind11/common.h b/include/pybind11/common.h index 9e9af98d8..48fee4413 100644 --- a/include/pybind11/common.h +++ b/include/pybind11/common.h @@ -235,6 +235,23 @@ struct buffer_info { } } + buffer_info(buffer_info &&other){ + (*this) = std::move(other); + } + + buffer_info& operator=(buffer_info &&rhs){ + ptr = rhs.ptr; + itemsize = rhs.itemsize; + size = rhs.size; + format = std::move(rhs.format); + ndim = rhs.ndim; + shape = std::move(rhs.shape); + strides = std::move(rhs.strides); + std::swap(view, rhs.view); + std::swap(ownview, rhs.ownview); + return *this; + } + ~buffer_info() { if (view && ownview) { PyBuffer_Release(view); delete view; } }