UList, FixedList: Correct swap member function

Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1787
This commit is contained in:
Henry Weller
2015-07-15 12:10:05 +01:00
parent 30af1cdbc4
commit 3599b8918b
5 changed files with 42 additions and 21 deletions

View File

@ -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
}

View File

@ -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) \

View File

@ -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
}