mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
consistency update
- OSspecific: chmod() -> chMod(), even although it's not used anywhere - ListOps get subset() and inplaceSubset() templated on BoolListType - added UList<bool>::operator[](..) const specialization. Returns false (actually pTraits<bool>::zero) for out-of-range elements. This lets us use List<bool> with lazy evaluation and no noticeable change in performance. - use rcIndex() and fcIndex() wherever possible. Could check if branching or modulus is faster for fcIndex(). - UList and FixedList get 'const T* cdata() const' and 'T* data()' members. Similar to the STL front() and std::string::data() methods, they return a pointer to the first element without needing to write '&myList[0]', recast begin() or violate const-ness.
This commit is contained in:
@ -77,14 +77,22 @@ int main(int argc, char *argv[])
|
||||
const PackedList<3>& constLst = list1;
|
||||
Info<< "\ntest operator[] const with out-of-range index\n";
|
||||
constLst.print(Info);
|
||||
if (!constLst[20])
|
||||
if (constLst[20])
|
||||
{
|
||||
Info<< "[20] is true (unexpected)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "[20] is false (expected) list size should be unchanged (const)\n";
|
||||
}
|
||||
constLst.print(Info);
|
||||
|
||||
Info<< "\ntest operator[] non-const with out-of-range index\n";
|
||||
if (!list1[20])
|
||||
if (list1[20])
|
||||
{
|
||||
Info<< "[20] is true (unexpected)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "[20] is false (expected) but list was resized?? (non-const)\n";
|
||||
}
|
||||
@ -268,6 +276,23 @@ int main(int argc, char *argv[])
|
||||
Info<< "removed final value: " << list3.remove() << endl;
|
||||
list3.print(Info);
|
||||
|
||||
|
||||
List<bool> list4(4, true);
|
||||
{
|
||||
const List<bool>& constLst = list4;
|
||||
Info<< "\ntest operator[] const with out-of-range index\n";
|
||||
Info<< constLst << endl;
|
||||
if (constLst[20])
|
||||
{
|
||||
Info<< "[20] is true (unexpected)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "[20] is false (expected) list size should be unchanged (const)\n";
|
||||
}
|
||||
Info<< constLst << endl;
|
||||
}
|
||||
|
||||
Info<< "\n\nDone.\n";
|
||||
|
||||
return 0;
|
||||
|
||||
@ -69,7 +69,7 @@ void checkFaceEdges
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
label fp1 = (fp + 1) % f.size();
|
||||
label fp1 = f.fcIndex(fp);
|
||||
|
||||
if (edges[myEdges[fp]] != edge(f[fp], f[fp1]))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user