mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
PackedList iterator bugfix
- compare iteratorBase == iteratorBase by value, not position
thus this works
list[a] == list[b] ...
- compare iterator == iteratorBase and const_iterator == iteratorBase
by position, not value. The inheritance rules means that this works:
iter == list.end() ...
this will compare positions:
iter == list[5];
Of course, this will still compare values:
*iter == list[5];
This commit is contained in:
@ -73,6 +73,50 @@ int main(int argc, char *argv[])
|
||||
list1[1] = list1[8] = list1[10] = list1[14] = 2;
|
||||
list1.print(Info);
|
||||
|
||||
|
||||
Info<< "\ntest operator== between references\n";
|
||||
if (list1[1] == list1[8])
|
||||
{
|
||||
Info<< "[1] == [8] (expected)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "[1] != [8] (unexpected)\n";
|
||||
}
|
||||
|
||||
if (list1[0] != list1[1])
|
||||
{
|
||||
Info<< "[0] != [1] (expected)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "[0] == [1] (unexpected)\n";
|
||||
}
|
||||
|
||||
Info<< "\ntest operator== with iterator\n";
|
||||
{
|
||||
PackedList<3>::iterator iter = list1[1];
|
||||
|
||||
if (iter != list1[8])
|
||||
{
|
||||
Info<< "iter != [8] (expected)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "iter == [8] (unexpected)\n";
|
||||
}
|
||||
|
||||
if (*iter != list1[8])
|
||||
{
|
||||
Info<< "*iter != [8] (unexpected)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "*iter == [8] (expected)\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
const PackedList<3>& constLst = list1;
|
||||
Info<< "\ntest operator[] const with out-of-range index\n";
|
||||
|
||||
Reference in New Issue
Block a user