mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add possibility to change const reference in tmp.
- previously it was only possible to reset a pointer, but not to change a const-reference directly (needed a swap() to do this).
This commit is contained in:
committed by
Andrew Heather
parent
de673f3bcf
commit
e3e0d7c8b9
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
@ -217,6 +217,9 @@ public:
|
||||
//- Delete managed temporary object and set to new given pointer
|
||||
inline void reset(T* p) noexcept;
|
||||
|
||||
//- Delete managed temporary object and set to const reference
|
||||
inline void cref(const T& obj) noexcept;
|
||||
|
||||
//- Swaps the managed object with other tmp.
|
||||
inline void swap(tmp<T>& other) noexcept;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -356,6 +356,15 @@ inline void Foam::tmp<T>::reset(T* p) noexcept
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::tmp<T>::cref(const T& obj) noexcept
|
||||
{
|
||||
clear();
|
||||
ptr_ = const_cast<T*>(&obj);
|
||||
type_ = CREF;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::tmp<T>::swap(tmp<T>& other) noexcept
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016 OpenFOAM Foundation
|
||||
@ -198,6 +198,9 @@ public:
|
||||
//- Delete managed temporary object and set to new given pointer
|
||||
inline void reset(T* p) noexcept;
|
||||
|
||||
//- Delete managed temporary object and set to const reference
|
||||
inline void cref(const T& obj) noexcept;
|
||||
|
||||
//- Swaps the managed object with other tmpNrc.
|
||||
inline void swap(tmpNrc<T>& other) noexcept;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 OpenFOAM Foundation
|
||||
@ -306,6 +306,15 @@ inline void Foam::tmpNrc<T>::reset(T* p) noexcept
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::tmpNrc<T>::cref(const T& obj) noexcept
|
||||
{
|
||||
clear();
|
||||
ptr_ = const_cast<T*>(&obj);
|
||||
type_ = CREF;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::tmpNrc<T>::swap(tmpNrc<T>& other) noexcept
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user