diff --git a/applications/test/sliceRange/Make/files b/applications/test/sliceRange/Make/files index 6d24718f23..1446894ea3 100644 --- a/applications/test/sliceRange/Make/files +++ b/applications/test/sliceRange/Make/files @@ -1,3 +1,3 @@ -Test-sliceRange.C +Test-sliceRange.cxx EXE = $(FOAM_USER_APPBIN)/Test-sliceRange diff --git a/applications/test/sliceRange/Test-sliceRange.C b/applications/test/sliceRange/Test-sliceRange.cxx similarity index 96% rename from applications/test/sliceRange/Test-sliceRange.C rename to applications/test/sliceRange/Test-sliceRange.cxx index b3f4f8df8b..a9b4190ebe 100644 --- a/applications/test/sliceRange/Test-sliceRange.C +++ b/applications/test/sliceRange/Test-sliceRange.cxx @@ -25,6 +25,7 @@ License Description Test slice range + \*---------------------------------------------------------------------------*/ #include "argList.H" @@ -157,7 +158,7 @@ int main(int argc, char *argv[]) // Some iterator tests { - const sliceRange range(25, 8, 3); + sliceRange range(25, 8, 3); auto iter1 = range.begin(); Info<< nl << "Forward iterator for " << range << nl; @@ -166,6 +167,16 @@ int main(int argc, char *argv[]) auto iter2 = range.rbegin(); Info<< nl << "Reverse iterator for " << range << nl; printIteratorTest(iter2); + + + // Change the start, size + range.start() = 5; + range.size() = 4; + + iter1 = range.begin(); + + Info<< nl << "Forward iterator for " << range << nl; + printIteratorTest(iter1); } diff --git a/src/OpenFOAM/primitives/ranges/sliceRange/sliceRange.H b/src/OpenFOAM/primitives/ranges/sliceRange/sliceRange.H index 6badfc0523..35176c42fb 100644 --- a/src/OpenFOAM/primitives/ranges/sliceRange/sliceRange.H +++ b/src/OpenFOAM/primitives/ranges/sliceRange/sliceRange.H @@ -112,23 +112,33 @@ public: // Access - //- The start value in the range - constexpr label start() const noexcept { return start_; } - - //- The size of the range - constexpr label size() const noexcept { return size_; } - - //- The stride for the range - constexpr label stride() const noexcept { return stride_; } - //- True if range is empty (zero-sized) bool empty() const noexcept { return !size_; } //- True if range has size greater than zero bool good() const noexcept { return (size_ > 0); } - //- The (inclusive) lower value of the range. - constexpr label min() const noexcept { return start_; } + //- The size of the range + label size() const noexcept { return size_; } + + //- Non-const access to size of the range + label& size() noexcept { return size_; } + + //- The (inclusive) lower value of the range + label start() const noexcept { return start_; } + + //- Non-const access to start of the range + label& start() noexcept { return start_; } + + //- The stride for the range + label stride() const noexcept { return stride_; } + + //- Non-const access to the stride + label& stride() noexcept { return stride_; } + + //- The (inclusive) lower value of the range, + //- same as start() + label min() const noexcept { return start_; } //- The (inclusive) upper value of the range. //- Ill-defined for an empty range @@ -195,7 +205,7 @@ public: class indexer { //- The stride when indexing - const label stride_; + label stride_; //- The global value label value_;