Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
9d5cb575
Commit
9d5cb575
authored
May 28, 2018
by
Mark OLESEN
Browse files
ENH: additional methods for tmpNrc (as per tmp)
- move constructable - factory methods: New, NewFrom - reset methods
parent
369604e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/memory/tmp/tmpNrc.H
View file @
9d5cb575
...
...
@@ -85,6 +85,26 @@ public:
typedef
Foam
::
refCount
::
zero
refCount
;
// Factory Methods
//- Construct tmpNrc of T with forwarding arguments
// \param args list of arguments with which an instance of T
// will be constructed.
//
// \note Similar to std::make_shared, but the overload for
// array types is not disabled.
template
<
class
...
Args
>
inline
static
tmpNrc
<
T
>
New
(
Args
&&
...
args
);
//- Construct tmpNrc from derived type with forwarding arguments
// \param args list of arguments with which an instance of U
// will be constructed.
//
// \note Similar to New but for derived types
template
<
class
U
,
class
...
Args
>
inline
static
tmpNrc
<
T
>
NewFrom
(
Args
&&
...
args
);
// Constructors
//- Construct with no managed pointer.
...
...
@@ -99,6 +119,9 @@ public:
//- Construct for a const reference to an object.
inline
tmpNrc
(
const
T
&
obj
)
noexcept
;
//- Move construct
inline
tmpNrc
(
tmpNrc
<
T
>&&
t
);
//- Copy construct
inline
tmpNrc
(
const
tmpNrc
<
T
>&
t
);
...
...
@@ -160,6 +183,13 @@ public:
//- delete object and set pointer to nullptr
inline
void
clear
()
const
;
//- Release ownership of managed temporary object.
// After this call no object is managed.
inline
void
reset
();
//- Delete managed temporary object and set to new given pointer
inline
void
reset
(
T
*
p
);
//- Swaps the managed object with other tmpNrc.
inline
void
swap
(
tmpNrc
<
T
>&
other
)
noexcept
;
...
...
src/OpenFOAM/memory/tmp/tmpNrcI.H
View file @
9d5cb575
...
...
@@ -26,6 +26,24 @@ License
#include
"error.H"
#include
<typeinfo>
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template
<
class
T
>
template
<
class
...
Args
>
inline
Foam
::
tmpNrc
<
T
>
Foam
::
tmpNrc
<
T
>::
New
(
Args
&&
...
args
)
{
return
tmpNrc
<
T
>
(
new
T
(
std
::
forward
<
Args
>
(
args
)...));
}
template
<
class
T
>
template
<
class
U
,
class
...
Args
>
inline
Foam
::
tmpNrc
<
T
>
Foam
::
tmpNrc
<
T
>::
NewFrom
(
Args
&&
...
args
)
{
return
tmpNrc
<
T
>
(
new
U
(
std
::
forward
<
Args
>
(
args
)...));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
class
T
>
...
...
@@ -60,6 +78,17 @@ inline Foam::tmpNrc<T>::tmpNrc(const T& obj) noexcept
{}
template
<
class
T
>
inline
Foam
::
tmpNrc
<
T
>::
tmpNrc
(
tmpNrc
<
T
>&&
t
)
:
ptr_
(
t
.
ptr_
),
type_
(
t
.
type_
)
{
t
.
ptr_
=
nullptr
;
t
.
type_
=
PTR
;
}
template
<
class
T
>
inline
Foam
::
tmpNrc
<
T
>::
tmpNrc
(
const
tmpNrc
<
T
>&
t
)
:
...
...
@@ -243,6 +272,24 @@ inline void Foam::tmpNrc<T>::clear() const
}
template
<
class
T
>
inline
void
Foam
::
tmpNrc
<
T
>::
reset
()
{
clear
();
ptr_
=
nullptr
;
type_
=
PTR
;
}
template
<
class
T
>
inline
void
Foam
::
tmpNrc
<
T
>::
reset
(
T
*
p
)
{
clear
();
ptr_
=
p
;
type_
=
PTR
;
}
template
<
class
T
>
inline
void
Foam
::
tmpNrc
<
T
>::
swap
(
tmpNrc
<
T
>&
other
)
noexcept
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment