mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: cannot compare 'this' for different DynamicList types
- Eg, cannot compare addresses of DynamicList<T,16> and DynamicList<T,8> [clang], so compare their cdata pointers instead.
This commit is contained in:
@ -397,7 +397,8 @@ inline void Foam::DynamicList<T, SizeMin>::swap
|
|||||||
DynamicList<T, AnySizeMin>& lst
|
DynamicList<T, AnySizeMin>& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (this == &lst)
|
// Cannot compare 'this' for different types, so use cdata()
|
||||||
|
if (this->cdata() == lst.cdata())
|
||||||
{
|
{
|
||||||
return; // Self-swap is a no-op
|
return; // Self-swap is a no-op
|
||||||
}
|
}
|
||||||
@ -439,7 +440,8 @@ Foam::DynamicList<T, SizeMin>::transfer
|
|||||||
DynamicList<T, AnySizeMin>& lst
|
DynamicList<T, AnySizeMin>& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (this == &lst)
|
// Cannot compare 'this' for different types, so use cdata()
|
||||||
|
if (this->cdata() == lst.cdata())
|
||||||
{
|
{
|
||||||
return; // Self-assignment is a no-op
|
return; // Self-assignment is a no-op
|
||||||
}
|
}
|
||||||
@ -811,18 +813,19 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
|
|||||||
|
|
||||||
|
|
||||||
template<class T, int SizeMin>
|
template<class T, int SizeMin>
|
||||||
template<int SizeMin2>
|
template<int AnySizeMin>
|
||||||
inline void Foam::DynamicList<T, SizeMin>::operator=
|
inline void Foam::DynamicList<T, SizeMin>::operator=
|
||||||
(
|
(
|
||||||
const DynamicList<T, SizeMin2>& lst
|
const DynamicList<T, AnySizeMin>& list
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (this == &lst)
|
// Cannot compare 'this' for different types, so use cdata()
|
||||||
|
if (this->cdata() == list.cdata())
|
||||||
{
|
{
|
||||||
return; // Self-assignment is a no-op
|
return; // Self-assignment is a no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
assignDynList(lst);
|
assignDynList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -875,19 +878,20 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
|
|||||||
|
|
||||||
|
|
||||||
template<class T, int SizeMin>
|
template<class T, int SizeMin>
|
||||||
template<int SizeMin2>
|
template<int AnySizeMin>
|
||||||
inline void Foam::DynamicList<T, SizeMin>::operator=
|
inline void Foam::DynamicList<T, SizeMin>::operator=
|
||||||
(
|
(
|
||||||
DynamicList<T, SizeMin2>&& lst
|
DynamicList<T, AnySizeMin>&& list
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (this == &lst)
|
// Cannot compare 'this' for different types, so use cdata()
|
||||||
|
if (this->cdata() == list.cdata())
|
||||||
{
|
{
|
||||||
return; // Self-assignment is a no-op
|
return; // Self-assignment is a no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
transfer(lst);
|
transfer(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -471,7 +471,8 @@ inline void Foam::PtrDynList<T, SizeMin>::operator=
|
|||||||
const PtrDynList<T, AnySizeMin>& list
|
const PtrDynList<T, AnySizeMin>& list
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (this == &list)
|
// Cannot compare 'this' for different types, so use cdata()
|
||||||
|
if (this->cdata() == list.cdata())
|
||||||
{
|
{
|
||||||
return; // Self-assignment is a no-op
|
return; // Self-assignment is a no-op
|
||||||
}
|
}
|
||||||
@ -522,7 +523,8 @@ inline void Foam::PtrDynList<T, SizeMin>::operator=
|
|||||||
PtrDynList<T, AnySizeMin>&& list
|
PtrDynList<T, AnySizeMin>&& list
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (this == &list)
|
// Cannot compare 'this' for different types, so use cdata()
|
||||||
|
if (this->cdata() == list.cdata())
|
||||||
{
|
{
|
||||||
return; // Self-assignment is a no-op
|
return; // Self-assignment is a no-op
|
||||||
}
|
}
|
||||||
|
|||||||
@ -399,12 +399,13 @@ inline void Foam::DynamicField<T, SizeMin>::swap
|
|||||||
DynamicField<T, AnySizeMin>& lst
|
DynamicField<T, AnySizeMin>& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (this == &lst)
|
// Cannot compare 'this' for different types, so use cdata()
|
||||||
|
if (this->cdata() == lst.cdata())
|
||||||
{
|
{
|
||||||
return; // Self-swap is a no-op
|
return; // Self-swap is a no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicList<T, SizeMin>& cur = *this;
|
DynamicField<T, SizeMin>& cur = *this;
|
||||||
|
|
||||||
// Make addressable size identical to the allocated capacity
|
// Make addressable size identical to the allocated capacity
|
||||||
const label oldSize1 = cur.expandStorage();
|
const label oldSize1 = cur.expandStorage();
|
||||||
@ -439,6 +440,12 @@ inline void Foam::DynamicField<T, SizeMin>::transfer
|
|||||||
DynamicList<T, AnySizeMin>& list
|
DynamicList<T, AnySizeMin>& list
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// Cannot compare 'this' for different types, so use cdata()
|
||||||
|
if (this->cdata() == list.cdata())
|
||||||
|
{
|
||||||
|
return; // Self-swap is a no-op
|
||||||
|
}
|
||||||
|
|
||||||
// Take over storage as-is (without shrink, without using SizeMin)
|
// Take over storage as-is (without shrink, without using SizeMin)
|
||||||
// clear addressing and storage for old list.
|
// clear addressing and storage for old list.
|
||||||
capacity_ = list.capacity();
|
capacity_ = list.capacity();
|
||||||
@ -455,9 +462,10 @@ inline void Foam::DynamicField<T, SizeMin>::transfer
|
|||||||
DynamicField<T, AnySizeMin>& list
|
DynamicField<T, AnySizeMin>& list
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (this == &list)
|
// Cannot compare 'this' for different types, so use cdata()
|
||||||
|
if (this->cdata() == list.cdata())
|
||||||
{
|
{
|
||||||
return; // Self-assignment is a no-op
|
return; // Self-swap is a no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take over storage as-is (without shrink, without using SizeMin)
|
// Take over storage as-is (without shrink, without using SizeMin)
|
||||||
|
|||||||
Reference in New Issue
Block a user