From 3565b5491f77bcc40a0981b918e9ee1ae19d64bd Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Mon, 23 May 2016 12:01:36 +0100 Subject: [PATCH] tmp: Added 'move' constructor to simplify return of unchanged 'tmp' arguments. --- src/OpenFOAM/memory/tmp/tmp.H | 3 +++ src/OpenFOAM/memory/tmp/tmpI.H | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/OpenFOAM/memory/tmp/tmp.H b/src/OpenFOAM/memory/tmp/tmp.H index 6a145158a7..5448b2533e 100644 --- a/src/OpenFOAM/memory/tmp/tmp.H +++ b/src/OpenFOAM/memory/tmp/tmp.H @@ -92,6 +92,9 @@ public: //- Construct copy and increment reference count inline tmp(const tmp&); + //- Construct copy moving content, does not increment reference count + inline tmp(const tmp&&); + //- Construct copy transferring content of temporary if required inline tmp(const tmp&, bool allowTransfer); diff --git a/src/OpenFOAM/memory/tmp/tmpI.H b/src/OpenFOAM/memory/tmp/tmpI.H index e08214bcd1..70a4dc2b7f 100644 --- a/src/OpenFOAM/memory/tmp/tmpI.H +++ b/src/OpenFOAM/memory/tmp/tmpI.H @@ -91,6 +91,19 @@ inline Foam::tmp::tmp(const tmp& t) } +template +inline Foam::tmp::tmp(const tmp&& t) +: + type_(t.type_), + ptr_(t.ptr_) +{ + if (isTmp()) + { + t.ptr_ = 0; + } +} + + template inline Foam::tmp::tmp(const tmp& t, bool allowTransfer) :