This commit is contained in:
@@ -12,7 +12,11 @@
|
||||
ss << #expr << "\""; \
|
||||
throw std::logic_error(ss.str()); \
|
||||
}
|
||||
#define AssertForEach(iterator, assertion) { for (auto item: iterator) Assert(assertion)}
|
||||
#define AssertForEach(iterator, assertion) \
|
||||
{ \
|
||||
for (auto item : iterator) \
|
||||
Assert(assertion) \
|
||||
}
|
||||
#else
|
||||
// Assert is empty if NO_ASSERT is defined.
|
||||
#define Assert(expr) ;
|
||||
|
||||
@@ -11,14 +11,13 @@ namespace Arbutils::Collections {
|
||||
|
||||
using iterator = typename std::unordered_map<KeyT, ValueT>::iterator;
|
||||
using const_iterator = typename std::unordered_map<KeyT, ValueT>::const_iterator;
|
||||
|
||||
public:
|
||||
Dictionary() : _map() {}
|
||||
explicit Dictionary(size_t capacity) : _map(capacity) {}
|
||||
explicit Dictionary(const std::initializer_list<std::pair<const KeyT, ValueT>>& l) : _map(l){}
|
||||
explicit Dictionary(const std::initializer_list<std::pair<const KeyT, ValueT>>& l) : _map(l) {}
|
||||
|
||||
inline void Clear(){
|
||||
_map.clear();
|
||||
}
|
||||
inline void Clear() { _map.clear(); }
|
||||
|
||||
inline void Insert(const KeyT& key, const ValueT& value) {
|
||||
[[maybe_unused]] const auto& v = _map.insert({key, value});
|
||||
@@ -28,7 +27,6 @@ namespace Arbutils::Collections {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline void Set(const KeyT& key, const ValueT& value) { _map[key] = value; }
|
||||
|
||||
[[nodiscard]] inline ValueT& Get(const KeyT& key) {
|
||||
@@ -39,9 +37,7 @@ namespace Arbutils::Collections {
|
||||
#endif
|
||||
}
|
||||
|
||||
[[nodiscard]] inline const ValueT& Get(const KeyT& key) const {
|
||||
return _map.at(key);
|
||||
}
|
||||
[[nodiscard]] inline const ValueT& Get(const KeyT& key) const { return _map.at(key); }
|
||||
|
||||
inline bool TryGet(const KeyT& key, ValueT& out) const {
|
||||
const auto& find = _map.find(key);
|
||||
@@ -52,9 +48,7 @@ namespace Arbutils::Collections {
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void Remove(const KeyT& key){
|
||||
_map.erase(key);
|
||||
}
|
||||
inline void Remove(const KeyT& key) { _map.erase(key); }
|
||||
|
||||
[[nodiscard]] inline size_t Count() const { return _map.size(); }
|
||||
|
||||
|
||||
3799
src/MacroUtils.hpp
3799
src/MacroUtils.hpp
File diff suppressed because one or more lines are too long
@@ -2,8 +2,7 @@
|
||||
#define ARBUTILS_BORROWEDPTR_HPP
|
||||
|
||||
namespace Arbutils::Memory {
|
||||
template <class>
|
||||
class NonNullBorrowedPtr;
|
||||
template <class> class NonNullBorrowedPtr;
|
||||
|
||||
template <class T> class BorrowedPtr {
|
||||
T* _ptr;
|
||||
@@ -16,9 +15,7 @@ namespace Arbutils::Memory {
|
||||
inline constexpr const T* GetUnsafe() const noexcept { return _ptr; }
|
||||
inline constexpr bool IsNull() const noexcept { return _ptr == nullptr; }
|
||||
|
||||
inline NonNullBorrowedPtr<T> GetNonNull() const {
|
||||
return NonNullBorrowedPtr<T>(_ptr);
|
||||
}
|
||||
inline NonNullBorrowedPtr<T> GetNonNull() const { return NonNullBorrowedPtr<T>(_ptr); }
|
||||
|
||||
T* operator->() noexcept { return _ptr; }
|
||||
T* operator->() const noexcept { return _ptr; }
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "BorrowedPtr.hpp"
|
||||
|
||||
namespace Arbutils::Memory {
|
||||
template <class>
|
||||
class BorrowedPtr;
|
||||
template <class> class BorrowedPtr;
|
||||
|
||||
template <class T> class NonNullBorrowedPtr {
|
||||
private:
|
||||
@@ -18,9 +17,7 @@ namespace Arbutils::Memory {
|
||||
inline constexpr T* GetUnsafe() noexcept { return _ptr; }
|
||||
inline constexpr const T* GetUnsafe() const noexcept { return _ptr; }
|
||||
|
||||
inline BorrowedPtr<T> GetOptional() const {
|
||||
return BorrowedPtr<T>(_ptr);
|
||||
}
|
||||
inline BorrowedPtr<T> GetOptional() const { return BorrowedPtr<T>(_ptr); }
|
||||
|
||||
T* operator->() noexcept { return _ptr; }
|
||||
T* operator->() const noexcept { return _ptr; }
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#define ARBUTILS_NONNULLOWNPTR_HPP
|
||||
|
||||
#include "../Assert.hpp"
|
||||
#include "NonNullBorrowedPtr.hpp"
|
||||
#include "BorrowedPtr.hpp"
|
||||
#include "NonNullBorrowedPtr.hpp"
|
||||
|
||||
namespace Arbutils::Memory {
|
||||
template <class T> class NonNullOwnPtr {
|
||||
|
||||
Reference in New Issue
Block a user