src: more cleanups; NFCI

This commit is contained in:
Markus F.X.J. Oberhumer
2022-09-15 01:14:38 +02:00
parent 81176716d5
commit b8b94ee89e
17 changed files with 226 additions and 150 deletions
+16 -5
View File
@@ -48,23 +48,33 @@ private:
#include "xspan_impl_common.h"
public:
// constructors from pointers
CSelf(pointer first) : ptr(makePtr(first)), base(nullptr), size_in_bytes(0) {}
CSelf(pointer first) : ptr(makePtr(first)), base(nullptr), size_in_bytes(0) {
assertInvariants();
}
// constructors
CSelf(const Self &other)
: ptr(other.ensurePtr()), base(other.base), size_in_bytes(other.size_in_bytes) {}
: ptr(other.ensurePtr()), base(other.base), size_in_bytes(other.size_in_bytes) {
assertInvariants();
}
template <class U>
CSelf(const CSelf<U> &other, SPAN_REQUIRES_CONVERTIBLE_A)
: ptr(other.ensurePtr()), base(other.base), size_in_bytes(other.size_in_bytes) {}
: ptr(other.ensurePtr()), base(other.base), size_in_bytes(other.size_in_bytes) {
assertInvariants();
}
// constructors from Span friends
template <class U>
CSelf(const Span<U> &other, SPAN_REQUIRES_CONVERTIBLE_A)
: ptr(other.ensurePtr()), base(other.base), size_in_bytes(other.size_in_bytes) {}
: ptr(other.ensurePtr()), base(other.base), size_in_bytes(other.size_in_bytes) {
assertInvariants();
}
#if SPAN_CONFIG_ENABLE_SPAN_CONVERSION
template <class U>
CSelf(const PtrOrSpanOrNull<U> &other, SPAN_REQUIRES_CONVERTIBLE_A)
: ptr(other.ensurePtr()), base(other.base), size_in_bytes(other.size_in_bytes) {}
: ptr(other.ensurePtr()), base(other.base), size_in_bytes(other.size_in_bytes) {
assertInvariants();
}
#endif
// assignment from Span friends
@@ -107,6 +117,7 @@ public:
#undef CSelf
};
// raw_bytes overload
template <class T>
inline T *raw_bytes(const PtrOrSpan<T> &a, size_t size_in_bytes) {
return a.raw_bytes(size_in_bytes);