mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
UList, FixedList: Correct swap member function
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1787
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -26,8 +26,6 @@ License
|
||||
#include "FixedList.H"
|
||||
#include "ListLoopM.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T, unsigned Size>
|
||||
@ -37,8 +35,8 @@ void Foam::FixedList<T, Size>::swap(FixedList<T, Size>& a)
|
||||
List_ACCESS(T, a, ap);
|
||||
T tmp;
|
||||
List_FOR_ALL((*this), i)
|
||||
tmp = List_ELEM((*this), vp, i);
|
||||
List_ELEM((*this), vp, i) = List_ELEM(a, ap, i);
|
||||
tmp = List_CELEM((*this), vp, i);
|
||||
List_ELEM((*this), vp, i) = List_CELEM(a, ap, i);
|
||||
List_ELEM(a, ap, i) = tmp;
|
||||
List_END_FOR_ALL
|
||||
}
|
||||
|
||||
@ -43,6 +43,10 @@ Description
|
||||
|
||||
#define List_END_FOR_ALL }
|
||||
|
||||
// Provide current element
|
||||
#define List_CELEM(f, fp, i) (fp[i])
|
||||
|
||||
// Provide current element
|
||||
#define List_ELEM(f, fp, i) (fp[i])
|
||||
|
||||
#define List_ACCESS(type, f, fp) \
|
||||
@ -62,6 +66,10 @@ Description
|
||||
|
||||
#define List_END_FOR_ALL }
|
||||
|
||||
// Provide current element without incrementing pointer
|
||||
#define List_CELEM(f, fp, i) (*fp)
|
||||
|
||||
// Provide current element and increment pointer
|
||||
#define List_ELEM(f, fp, i) (*fp++)
|
||||
|
||||
#define List_ACCESS(type, f, fp) \
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -46,13 +46,13 @@ void Foam::UList<T>::assign(const UList<T>& a)
|
||||
|
||||
if (this->size_)
|
||||
{
|
||||
# ifdef USEMEMCPY
|
||||
#ifdef USEMEMCPY
|
||||
if (contiguous<T>())
|
||||
{
|
||||
memcpy(this->v_, a.v_, this->byteSize());
|
||||
}
|
||||
else
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
List_ACCESS(T, (*this), vp);
|
||||
List_CONST_ACCESS(T, a, ap);
|
||||
@ -93,8 +93,8 @@ void Foam::UList<T>::swap(UList<T>& a)
|
||||
List_ACCESS(T, a, ap);
|
||||
T tmp;
|
||||
List_FOR_ALL((*this), i)
|
||||
tmp = List_ELEM((*this), vp, i);
|
||||
List_ELEM((*this), vp, i) = List_ELEM(a, ap, i);
|
||||
tmp = List_CELEM((*this), vp, i);
|
||||
List_ELEM((*this), vp, i) = List_CELEM(a, ap, i);
|
||||
List_ELEM(a, ap, i) = tmp;
|
||||
List_END_FOR_ALL
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user