Implements easier assertions for iterators
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:
@@ -12,12 +12,12 @@
|
||||
ss << #expr << "\""; \
|
||||
throw std::logic_error(ss.str()); \
|
||||
}
|
||||
#define AssertForEach(iterator, assertion) { for (auto item: iterator) Assert(assertion)}
|
||||
#else
|
||||
// Assert is empty if NO_ASSERT is defined.
|
||||
#define Assert(expr) ;
|
||||
#define AssertForEach(iterator, assertion) ;
|
||||
#endif
|
||||
|
||||
#define AssertNotNull(value) Assert(value != nullptr)
|
||||
#define UnpackWeakPtr(weakPtr, sharedPtr) \
|
||||
Assert(!weakPtr.expired()); \
|
||||
auto sharedPtr = weakPtr.lock();
|
||||
#define AssertAllNotNull(iterator) AssertForEach(iterator, item != nullptr)
|
||||
|
||||
Reference in New Issue
Block a user