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
c6c30a06
Commit
c6c30a06
authored
Jan 15, 2019
by
Mark OLESEN
Browse files
ENH: return const pointer instead of bool from PtrList::set(label)
- can still test as a bool or use to 'peek' at the content.
parent
1ce8440c
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/containers/PtrLists/PtrList/PtrList.H
View file @
c6c30a06
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2018
-2019
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -150,21 +150,22 @@ public:
//- Transfer into this list and annul the argument list
inline
void
transfer
(
PtrList
<
T
>&
list
);
//- Return true if element is set (ie, not a nullptr)
inline
bool
set
(
const
label
i
)
const
;
//- Return const pointer to element (if set) or nullptr.
// The return value can be tested as a bool.
inline
const
T
*
set
(
const
label
i
)
const
;
//- Set element to given pointer and return old element (can be null)
// No-op if the new pointer value is identical to the current content.
inline
autoPtr
<
T
>
set
(
label
i
,
T
*
ptr
);
inline
autoPtr
<
T
>
set
(
const
label
i
,
T
*
ptr
);
//- Set element to given autoPtr and return old element
inline
autoPtr
<
T
>
set
(
label
i
,
autoPtr
<
T
>&
aptr
);
inline
autoPtr
<
T
>
set
(
const
label
i
,
autoPtr
<
T
>&
aptr
);
//- Set element to given autoPtr and return old element
inline
autoPtr
<
T
>
set
(
label
i
,
autoPtr
<
T
>&&
aptr
);
inline
autoPtr
<
T
>
set
(
const
label
i
,
autoPtr
<
T
>&&
aptr
);
//- Set element to given tmp and return old element
inline
autoPtr
<
T
>
set
(
label
i
,
const
tmp
<
T
>&
tptr
);
inline
autoPtr
<
T
>
set
(
const
label
i
,
const
tmp
<
T
>&
tptr
);
// Member Operators
...
...
src/OpenFOAM/containers/PtrLists/PtrList/PtrListI.H
View file @
c6c30a06
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2018
-2019
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -123,35 +123,35 @@ inline void Foam::PtrList<T>::append(const tmp<T>& tptr)
template
<
class
T
>
inline
bool
Foam
::
PtrList
<
T
>::
set
(
const
label
i
)
const
inline
const
T
*
Foam
::
PtrList
<
T
>::
set
(
const
label
i
)
const
{
return
UPtrList
<
T
>::
set
(
i
);
}
template
<
class
T
>
inline
Foam
::
autoPtr
<
T
>
Foam
::
PtrList
<
T
>::
set
(
label
i
,
T
*
ptr
)
inline
Foam
::
autoPtr
<
T
>
Foam
::
PtrList
<
T
>::
set
(
const
label
i
,
T
*
ptr
)
{
return
autoPtr
<
T
>
(
UPtrList
<
T
>::
set
(
i
,
ptr
));
}
template
<
class
T
>
inline
Foam
::
autoPtr
<
T
>
Foam
::
PtrList
<
T
>::
set
(
label
i
,
autoPtr
<
T
>&
aptr
)
inline
Foam
::
autoPtr
<
T
>
Foam
::
PtrList
<
T
>::
set
(
const
label
i
,
autoPtr
<
T
>&
aptr
)
{
return
set
(
i
,
aptr
.
release
());
}
template
<
class
T
>
inline
Foam
::
autoPtr
<
T
>
Foam
::
PtrList
<
T
>::
set
(
label
i
,
autoPtr
<
T
>&&
aptr
)
inline
Foam
::
autoPtr
<
T
>
Foam
::
PtrList
<
T
>::
set
(
const
label
i
,
autoPtr
<
T
>&&
aptr
)
{
return
set
(
i
,
aptr
.
release
());
}
template
<
class
T
>
inline
Foam
::
autoPtr
<
T
>
Foam
::
PtrList
<
T
>::
set
(
label
i
,
const
tmp
<
T
>&
tptr
)
inline
Foam
::
autoPtr
<
T
>
Foam
::
PtrList
<
T
>::
set
(
const
label
i
,
const
tmp
<
T
>&
tptr
)
{
return
set
(
i
,
tptr
.
ptr
());
}
...
...
src/OpenFOAM/containers/PtrLists/UPtrList/UPtrList.H
View file @
c6c30a06
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2018
-2019
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -177,8 +177,9 @@ public:
//- Transfer contents into this list and annul the argument
inline
void
transfer
(
UPtrList
<
T
>&
list
);
//- Return true if element is set (not a nullptr)
inline
bool
set
(
const
label
i
)
const
;
//- Return const pointer to element (if set) or nullptr.
// The return value can be tested as a bool.
inline
const
T
*
set
(
const
label
i
)
const
;
//- Set element to specified pointer and return the old list element,
//- which can be a nullptr.
...
...
src/OpenFOAM/containers/PtrLists/UPtrList/UPtrListI.H
View file @
c6c30a06
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2018
-2019
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -170,9 +170,9 @@ inline void Foam::UPtrList<T>::append(T* ptr)
template
<
class
T
>
inline
bool
Foam
::
UPtrList
<
T
>::
set
(
const
label
i
)
const
inline
const
T
*
Foam
::
UPtrList
<
T
>::
set
(
const
label
i
)
const
{
return
ptrs_
[
i
]
!=
nullptr
;
return
ptrs_
[
i
];
}
...
...
@@ -199,7 +199,7 @@ inline const T& Foam::UPtrList<T>::operator[](const label i) const
if
(
!
ptr
)
{
FatalErrorInFunction
<<
"
c
annot dereference nullptr at index "
<<
i
<<
"
C
annot dereference nullptr at index "
<<
i
<<
" in range [0,"
<<
size
()
<<
")"
<<
abort
(
FatalError
);
}
...
...
@@ -216,7 +216,7 @@ inline T& Foam::UPtrList<T>::operator[](const label i)
if
(
!
ptr
)
{
FatalErrorInFunction
<<
"
c
annot dereference nullptr at index "
<<
i
<<
"
C
annot dereference nullptr at index "
<<
i
<<
" in range [0,"
<<
size
()
<<
")"
<<
abort
(
FatalError
);
}
...
...
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