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 |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -369,7 +369,7 @@ Foam::List<T>::List(std::initializer_list<T> list)
|
||||
template<class T>
|
||||
Foam::List<T>::List(List<T>&& list)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
UList<T>()
|
||||
{
|
||||
// Can use transfer or swap to manage content
|
||||
transfer(list);
|
||||
@ -380,7 +380,7 @@ template<class T>
|
||||
template<int SizeMin>
|
||||
Foam::List<T>::List(DynamicList<T, SizeMin>&& list)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
UList<T>()
|
||||
{
|
||||
transfer(list);
|
||||
}
|
||||
@ -389,7 +389,7 @@ Foam::List<T>::List(DynamicList<T, SizeMin>&& list)
|
||||
template<class T>
|
||||
Foam::List<T>::List(SortableList<T>&& list)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
UList<T>()
|
||||
{
|
||||
transfer(list);
|
||||
}
|
||||
@ -398,7 +398,7 @@ Foam::List<T>::List(SortableList<T>&& list)
|
||||
template<class T>
|
||||
Foam::List<T>::List(SLList<T>&& list)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
UList<T>()
|
||||
{
|
||||
operator=(std::move(list));
|
||||
}
|
||||
@ -531,18 +531,33 @@ void Foam::List<T>::operator=(const SLList<T>& list)
|
||||
|
||||
if (len)
|
||||
{
|
||||
List_ACCESS(T, (*this), vp);
|
||||
T* iter = this->begin();
|
||||
|
||||
label i = 0;
|
||||
for (auto iter = list.cbegin(); iter != list.cend(); ++iter)
|
||||
for (const T& val : list)
|
||||
{
|
||||
vp[i] = *iter;
|
||||
++i;
|
||||
*iter = val;
|
||||
++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 Addr>
|
||||
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)
|
||||
{
|
||||
List_ACCESS(T, (*this), vp);
|
||||
T* iter = this->begin();
|
||||
|
||||
label i = 0;
|
||||
for (const T& val : list)
|
||||
{
|
||||
vp[i] = val;
|
||||
++i;
|
||||
*iter = val;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -614,18 +628,16 @@ void Foam::List<T>::operator=(SortableList<T>&& list)
|
||||
template<class T>
|
||||
void Foam::List<T>::operator=(SLList<T>&& list)
|
||||
{
|
||||
const label len = list.size();
|
||||
label len = list.size();
|
||||
|
||||
reAlloc(len);
|
||||
|
||||
if (len)
|
||||
{
|
||||
List_ACCESS(T, (*this), vp);
|
||||
T* iter = this->begin();
|
||||
|
||||
for (label i = 0; i < len; ++i)
|
||||
{
|
||||
vp[i] = std::move(list.removeHead());
|
||||
}
|
||||
while (len--)
|
||||
{
|
||||
*iter = std::move(list.removeHead());
|
||||
++iter;
|
||||
}
|
||||
|
||||
list.clear();
|
||||
|
||||
@ -52,7 +52,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
@ -268,6 +268,10 @@ public:
|
||||
template<class Addr>
|
||||
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
|
||||
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>
|
||||
void Foam::UList<T>::operator=(const T& val)
|
||||
{
|
||||
const label len = this->size();
|
||||
|
||||
List_ACCESS(T, (*this), vp);
|
||||
List_FOR_ALL((*this), i)
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
vp[i] = val;
|
||||
}
|
||||
@ -171,8 +174,11 @@ void Foam::UList<T>::operator=(const T& val)
|
||||
template<class T>
|
||||
void Foam::UList<T>::operator=(const zero)
|
||||
{
|
||||
const label len = this->size();
|
||||
|
||||
List_ACCESS(T, (*this), vp);
|
||||
List_FOR_ALL((*this), i)
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
vp[i] = Zero;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user