Skip to content

Commit fb84d41

Browse files
committed
CroppedArrayRef: also transitively establish base's invariants
1 parent a6ff1c4 commit fb84d41

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/librawspeed/adt/Array1DRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ template <class T> class Array1DRef final {
3333
T* data = nullptr;
3434
int numElts = 0;
3535

36-
void establishClassInvariants() const noexcept;
37-
3836
friend Array1DRef<const T>; // We need to be able to convert to const version.
3937

4038
// We need to be able to convert to std::byte.
4139
friend Array1DRef<std::byte>;
4240
friend Array1DRef<const std::byte>;
4341

4442
public:
43+
void establishClassInvariants() const noexcept;
44+
4545
using value_type = T;
4646
using cvless_value_type = std::remove_cv_t<value_type>;
4747

src/librawspeed/adt/Array2DRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ template <class T> class Array2DRef final {
3434
T* _data = nullptr;
3535
int _pitch = 0;
3636

37-
void establishClassInvariants() const noexcept;
38-
3937
friend Array2DRef<const T>; // We need to be able to convert to const version.
4038

4139
// We need to be able to convert to std::byte.
4240
friend Array2DRef<std::byte>;
4341
friend Array2DRef<const std::byte>;
4442

4543
public:
44+
void establishClassInvariants() const noexcept;
45+
4646
using value_type = T;
4747
using cvless_value_type = std::remove_cv_t<value_type>;
4848

src/librawspeed/adt/CroppedArray1DRef.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ template <class T> class CroppedArray1DRef final {
3232
int offset = 0;
3333
int numElts = 0;
3434

35-
void establishClassInvariants() const noexcept;
36-
3735
friend CroppedArray1DRef<const T>; // We need to be able to convert to const
3836
// version.
3937

@@ -43,6 +41,8 @@ template <class T> class CroppedArray1DRef final {
4341
CroppedArray1DRef(Array1DRef<T> base, int offset, int numElts);
4442

4543
public:
44+
void establishClassInvariants() const noexcept;
45+
4646
using value_type = T;
4747
using cvless_value_type = std::remove_cv_t<value_type>;
4848

@@ -87,6 +87,7 @@ CroppedArray1DRef(Array1DRef<T> base, int offset, int numElts)
8787

8888
template <class T>
8989
inline void CroppedArray1DRef<T>::establishClassInvariants() const noexcept {
90+
base.establishClassInvariants();
9091
invariant(offset >= 0);
9192
invariant(numElts >= 0);
9293
invariant(offset <= base.size());

src/librawspeed/adt/CroppedArray2DRef.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ namespace rawspeed {
3131
template <class T> class CroppedArray2DRef final {
3232
const Array2DRef<T> base;
3333

34-
void establishClassInvariants() const noexcept;
35-
3634
// We need to be able to convert to const version.
3735
friend CroppedArray2DRef<const T>;
3836

3937
public:
38+
void establishClassInvariants() const noexcept;
39+
4040
using value_type = T;
4141
using cvless_value_type = std::remove_cv_t<value_type>;
4242

@@ -88,6 +88,7 @@ explicit CroppedArray2DRef(Array2DRef<T> base_, int offsetCols_,
8888

8989
template <class T>
9090
inline void CroppedArray2DRef<T>::establishClassInvariants() const noexcept {
91+
base.establishClassInvariants();
9192
invariant(offsetCols >= 0);
9293
invariant(offsetRows >= 0);
9394
invariant(croppedWidth >= 0);

0 commit comments

Comments
 (0)