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
+17 -18
View File
@@ -52,12 +52,20 @@ pointer ptr; // current view into (base, base+size_in_bytes) iff base != nullptr
pointer base;
size_type size_in_bytes;
private:
// disable taking the address => force passing by reference
// [I'm not too sure about this design decision, but we can always allow it if needed]
Self *operator&() const SPAN_DELETED_FUNCTION;
// debug - internal sanity check; also serves as pseudo-documentation
#if DEBUG || 1
__acc_noinline void assertInvariants() const {
if __acc_cte (configRequirePtr)
assert(ptr != nullptr);
if __acc_cte (configRequireBase)
assert(base != nullptr);
if __acc_cte ((configRequirePtr || ptr != nullptr) && (configRequireBase || base != nullptr))
span_check_range(ptr, base, size_in_bytes);
}
#else
__acc_forceinline void assertInvariants() const {}
#endif
private:
static __acc_forceinline pointer makeNotNull(pointer p) {
if __acc_very_unlikely (p == nullptr)
span_fail_nullptr();
@@ -85,19 +93,6 @@ __acc_forceinline pointer ensureBase() const {
span_fail_nullptr();
return ptr;
}
// debug - extra internal sanity checks
#if DEBUG || 1
__acc_noinline void assertInvariants() const {
if __acc_cte (configRequirePtr)
assert(ptr != nullptr);
if __acc_cte (configRequireBase)
assert(base != nullptr);
if __acc_cte ((configRequirePtr || ptr != nullptr) && (configRequireBase || base != nullptr))
span_check_range(ptr, base, size_in_bytes);
}
#else
__acc_forceinline void assertInvariants() const {}
#endif
public:
inline ~CSelf() {}
@@ -397,6 +392,10 @@ pointer check_add(pointer p, ptrdiff_t n) const {
return p;
}
// disable taking the address => force passing by reference
// [I'm not too sure about this design decision, but we can always allow it if needed]
Self *operator&() const SPAN_DELETED_FUNCTION;
public: // raw access
pointer raw_ptr() const { return ptr; }
pointer raw_base() const { return base; }