mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: add copy assign List from FixedList (was missing)
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -369,7 +369,7 @@ Foam::List<T>::List(std::initializer_list<T> list)
|
|||||||
template<class T>
|
template<class T>
|
||||||
Foam::List<T>::List(List<T>&& list)
|
Foam::List<T>::List(List<T>&& list)
|
||||||
:
|
:
|
||||||
UList<T>(nullptr, 0)
|
UList<T>()
|
||||||
{
|
{
|
||||||
// Can use transfer or swap to manage content
|
// Can use transfer or swap to manage content
|
||||||
transfer(list);
|
transfer(list);
|
||||||
@ -380,7 +380,7 @@ template<class T>
|
|||||||
template<int SizeMin>
|
template<int SizeMin>
|
||||||
Foam::List<T>::List(DynamicList<T, SizeMin>&& list)
|
Foam::List<T>::List(DynamicList<T, SizeMin>&& list)
|
||||||
:
|
:
|
||||||
UList<T>(nullptr, 0)
|
UList<T>()
|
||||||
{
|
{
|
||||||
transfer(list);
|
transfer(list);
|
||||||
}
|
}
|
||||||
@ -389,7 +389,7 @@ Foam::List<T>::List(DynamicList<T, SizeMin>&& list)
|
|||||||
template<class T>
|
template<class T>
|
||||||
Foam::List<T>::List(SortableList<T>&& list)
|
Foam::List<T>::List(SortableList<T>&& list)
|
||||||
:
|
:
|
||||||
UList<T>(nullptr, 0)
|
UList<T>()
|
||||||
{
|
{
|
||||||
transfer(list);
|
transfer(list);
|
||||||
}
|
}
|
||||||
@ -398,7 +398,7 @@ Foam::List<T>::List(SortableList<T>&& list)
|
|||||||
template<class T>
|
template<class T>
|
||||||
Foam::List<T>::List(SLList<T>&& list)
|
Foam::List<T>::List(SLList<T>&& list)
|
||||||
:
|
:
|
||||||
UList<T>(nullptr, 0)
|
UList<T>()
|
||||||
{
|
{
|
||||||
operator=(std::move(list));
|
operator=(std::move(list));
|
||||||
}
|
}
|
||||||
@ -531,18 +531,33 @@ void Foam::List<T>::operator=(const SLList<T>& list)
|
|||||||
|
|
||||||
if (len)
|
if (len)
|
||||||
{
|
{
|
||||||
List_ACCESS(T, (*this), vp);
|
T* iter = this->begin();
|
||||||
|
|
||||||
label i = 0;
|
for (const T& val : list)
|
||||||
for (auto iter = list.cbegin(); iter != list.cend(); ++iter)
|
|
||||||
{
|
{
|
||||||
vp[i] = *iter;
|
*iter = val;
|
||||||
++i;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
template<unsigned N>
|
||||||
|
void Foam::List<T>::operator=(const FixedList<T, N>& list)
|
||||||
|
{
|
||||||
|
reAlloc(label(N));
|
||||||
|
|
||||||
|
T* iter = this->begin();
|
||||||
|
|
||||||
|
for (const T& val : list)
|
||||||
|
{
|
||||||
|
*iter = val;
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
template<class Addr>
|
template<class Addr>
|
||||||
void Foam::List<T>::operator=(const IndirectListBase<T, Addr>& list)
|
void Foam::List<T>::operator=(const IndirectListBase<T, Addr>& list)
|
||||||
@ -572,13 +587,12 @@ void Foam::List<T>::operator=(std::initializer_list<T> list)
|
|||||||
|
|
||||||
if (len)
|
if (len)
|
||||||
{
|
{
|
||||||
List_ACCESS(T, (*this), vp);
|
T* iter = this->begin();
|
||||||
|
|
||||||
label i = 0;
|
|
||||||
for (const T& val : list)
|
for (const T& val : list)
|
||||||
{
|
{
|
||||||
vp[i] = val;
|
*iter = val;
|
||||||
++i;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -614,18 +628,16 @@ void Foam::List<T>::operator=(SortableList<T>&& list)
|
|||||||
template<class T>
|
template<class T>
|
||||||
void Foam::List<T>::operator=(SLList<T>&& list)
|
void Foam::List<T>::operator=(SLList<T>&& list)
|
||||||
{
|
{
|
||||||
const label len = list.size();
|
label len = list.size();
|
||||||
|
|
||||||
reAlloc(len);
|
reAlloc(len);
|
||||||
|
|
||||||
if (len)
|
T* iter = this->begin();
|
||||||
{
|
|
||||||
List_ACCESS(T, (*this), vp);
|
|
||||||
|
|
||||||
for (label i = 0; i < len; ++i)
|
while (len--)
|
||||||
{
|
{
|
||||||
vp[i] = std::move(list.removeHead());
|
*iter = std::move(list.removeHead());
|
||||||
}
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
|
|||||||
@ -52,7 +52,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
@ -268,6 +268,10 @@ public:
|
|||||||
template<class Addr>
|
template<class Addr>
|
||||||
void operator=(const IndirectListBase<T, Addr>& list);
|
void operator=(const IndirectListBase<T, Addr>& list);
|
||||||
|
|
||||||
|
//- Copy assignment from FixedList
|
||||||
|
template<unsigned N>
|
||||||
|
void operator=(const FixedList<T, N>& list);
|
||||||
|
|
||||||
//- Assignment to an initializer list
|
//- Assignment to an initializer list
|
||||||
void operator=(std::initializer_list<T> list);
|
void operator=(std::initializer_list<T> list);
|
||||||
|
|
||||||
|
|||||||
@ -160,8 +160,11 @@ const Foam::UList<T> Foam::UList<T>::operator[](const labelRange& range) const
|
|||||||
template<class T>
|
template<class T>
|
||||||
void Foam::UList<T>::operator=(const T& val)
|
void Foam::UList<T>::operator=(const T& val)
|
||||||
{
|
{
|
||||||
|
const label len = this->size();
|
||||||
|
|
||||||
List_ACCESS(T, (*this), vp);
|
List_ACCESS(T, (*this), vp);
|
||||||
List_FOR_ALL((*this), i)
|
|
||||||
|
for (label i=0; i < len; ++i)
|
||||||
{
|
{
|
||||||
vp[i] = val;
|
vp[i] = val;
|
||||||
}
|
}
|
||||||
@ -171,8 +174,11 @@ void Foam::UList<T>::operator=(const T& val)
|
|||||||
template<class T>
|
template<class T>
|
||||||
void Foam::UList<T>::operator=(const zero)
|
void Foam::UList<T>::operator=(const zero)
|
||||||
{
|
{
|
||||||
|
const label len = this->size();
|
||||||
|
|
||||||
List_ACCESS(T, (*this), vp);
|
List_ACCESS(T, (*this), vp);
|
||||||
List_FOR_ALL((*this), i)
|
|
||||||
|
for (label i=0; i < len; ++i)
|
||||||
{
|
{
|
||||||
vp[i] = Zero;
|
vp[i] = Zero;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user