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) {} | ||||
|  | ||||
|         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(); } | ||||
|  | ||||
|   | ||||
							
								
								
									
										3041
									
								
								src/MacroUtils.hpp
									
									
									
									
									
								
							
							
						
						
									
										3041
									
								
								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 { | ||||
|   | ||||
| @@ -45,7 +45,8 @@ TEST_CASE("Use case insensitive const string in switch case", "[Utilities]") { | ||||
| #ifndef WINDOWS | ||||
| __attribute__((optnone)) | ||||
| #endif | ||||
| static Arbutils::CaseInsensitiveConstString TestCreateConstString(){ | ||||
| static Arbutils::CaseInsensitiveConstString | ||||
| TestCreateConstString() { | ||||
|     char originalVal[7]; | ||||
|     originalVal[0] = 'f'; | ||||
|     originalVal[1] = 'o'; | ||||
| @@ -65,13 +66,9 @@ TEST_CASE("Out of scope char* doesn't lose reference", "[Utilities]") { | ||||
|  | ||||
| TEST_CASE("Literal conststring to non literal, then use", "[Utilities]") { | ||||
|     Arbutils::CaseInsensitiveConstString val; | ||||
|     { | ||||
|         val = "foobar"_cnc; | ||||
|     } | ||||
|     { val = "foobar"_cnc; } | ||||
|     INFO(val.c_str()); | ||||
|     REQUIRE(strcmp(val.c_str(), "foobar") == 0); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| #endif | ||||
| @@ -19,7 +19,6 @@ TEST_CASE("Create List from initializer list", "[Utilities]") { | ||||
|     CHECK(ls.At(3) == -500); | ||||
| } | ||||
|  | ||||
|  | ||||
| TEST_CASE("Create List, insert values, retrieve values", "[Utilities]") { | ||||
|     auto ls = List<int>(); | ||||
|     ls.Append(5); | ||||
| @@ -68,7 +67,4 @@ TEST_CASE("Test IndexOf", "[Utilities]") { | ||||
|     CHECK(ls.IndexOf(684) == -1); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| #endif | ||||
| @@ -4,9 +4,7 @@ | ||||
| #include "../src/Memory/OwnPtr.hpp" | ||||
|  | ||||
| struct TestClass { | ||||
|     bool GetTestBool(){ | ||||
|         return true; | ||||
|     } | ||||
|     bool GetTestBool() { return true; } | ||||
| }; | ||||
|  | ||||
| TEST_CASE("Access OwnPtr", "[Utilities]") { | ||||
| @@ -23,5 +21,4 @@ TEST_CASE("Instantiate NonNullOwnPtr fails with nullptr", "[Utilities]") { | ||||
|     CHECK_THROWS(Arbutils::Memory::NonNullOwnPtr<TestClass>(nullptr)); | ||||
| } | ||||
|  | ||||
|  | ||||
| #endif | ||||
		Reference in New Issue
	
	Block a user