Rename Assert macro to Ensure, clean up exception to be in line with THROW.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -16,7 +16,7 @@ namespace ArbUt {
|
||||
public:
|
||||
inline BorrowedPtr<T>() {}
|
||||
/// @brief Initialise a BorrowedPtr with a specific raw pointer.
|
||||
inline BorrowedPtr<T>(T* ptr) : _raw(ptr) { AssertNotNull(ptr); };
|
||||
inline BorrowedPtr<T>(T* ptr) : _raw(ptr) { EnsureNotNull(ptr); };
|
||||
/// @brief Initialise a BorrowedPtr from a copy.
|
||||
inline BorrowedPtr<T>(const BorrowedPtr<T>& other) : _raw(other._raw){};
|
||||
/// @brief Initialise a BorrowedPtr with a std unique_ptr.
|
||||
@@ -39,7 +39,7 @@ namespace ArbUt {
|
||||
if (_raw == rhs) {
|
||||
return *this;
|
||||
}
|
||||
AssertNotNull(rhs);
|
||||
EnsureNotNull(rhs);
|
||||
_raw = rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace ArbUt {
|
||||
/// @brief Operator for access into underlying pointer.
|
||||
/// @warning Note that this asserts that the underlying pointer is not null first, to prevent segfaults.
|
||||
inline T* operator->() const noexcept {
|
||||
AssertNotNull(_raw);
|
||||
EnsureNotNull(_raw);
|
||||
return _raw;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace ArbUt {
|
||||
public:
|
||||
inline UniquePtr<T>() {}
|
||||
/// @brief Initialise a UniquePtr with a specific raw pointer.
|
||||
inline UniquePtr<T>(T* ptr) : _raw(ptr) { AssertNotNull(ptr); };
|
||||
inline UniquePtr<T>(T* ptr) : _raw(ptr) { EnsureNotNull(ptr); };
|
||||
/// @brief Initialise a UniquePtr from a copy.
|
||||
inline UniquePtr<T>(const UniquePtr<T>& other) : _raw(other._raw){};
|
||||
/// @brief Initialise a UniquePtr with a std unique_ptr.
|
||||
@@ -42,7 +42,7 @@ namespace ArbUt {
|
||||
return *this;
|
||||
}
|
||||
delete _raw;
|
||||
AssertNotNull(rhs);
|
||||
EnsureNotNull(rhs);
|
||||
_raw = rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace ArbUt {
|
||||
inline UniquePtrList() noexcept : _vector() {}
|
||||
/// @brief Initialises a UniquePtrList from a std::vector of raw pointers.
|
||||
/// @param vec A std::vector of raw pointers.
|
||||
inline UniquePtrList(const std::vector<ValueT*>& vec) noexcept : _vector(vec) { AssertAllNotNull(vec); }
|
||||
inline UniquePtrList(const std::vector<ValueT*>& vec) noexcept : _vector(vec) { EnsureAllNotNull(vec); }
|
||||
/// @brief Initialises a UniquePtrList with a certain capacity reserved for use. This does not set immediate
|
||||
/// size.
|
||||
/// @param capacity The desired capacity.
|
||||
@@ -25,13 +25,13 @@ namespace ArbUt {
|
||||
/// @brief Initialises a UniquePtrList from a initialiser_list.
|
||||
/// @param l A initialiser_list
|
||||
inline UniquePtrList(const std::initializer_list<ValueT*>& l) noexcept : _vector(l) {
|
||||
AssertAllNotNull(_vector);
|
||||
EnsureAllNotNull(_vector);
|
||||
}
|
||||
/// @brief Initialises a UniquePtrList from a raw pointer range.
|
||||
/// @param begin The raw pointer to the start of the list.
|
||||
/// @param end The raw pointer to the end of the list.
|
||||
inline UniquePtrList(ValueT* const* begin, ValueT* const* end) noexcept : _vector(begin, end) {
|
||||
AssertAllNotNull(_vector);
|
||||
EnsureAllNotNull(_vector);
|
||||
}
|
||||
|
||||
UniquePtrList(const UniquePtrList<ValueT>&) = delete;
|
||||
@@ -80,7 +80,7 @@ namespace ArbUt {
|
||||
/// @param index The index to set the pointer to.
|
||||
/// @param ptr The pointer to store.
|
||||
void Set(size_t index, ValueT* ptr) {
|
||||
AssertNotNull(ptr);
|
||||
EnsureNotNull(ptr);
|
||||
delete _vector[index];
|
||||
_vector[index] = ptr;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ namespace ArbUt {
|
||||
/// @brief Append a pointer to the list.
|
||||
/// @param value The pointer to push to the list.
|
||||
inline void Append(ValueT* value) {
|
||||
AssertNotNull(value);
|
||||
EnsureNotNull(value);
|
||||
_vector.push_back(value);
|
||||
}
|
||||
/// @brief Borrow a pointer at a certain index.
|
||||
|
||||
Reference in New Issue
Block a user