[ox/std] Make most of Optional constexpr
This commit is contained in:
		
							
								
								
									
										12
									
								
								deps/ox/src/ox/std/optional.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								deps/ox/src/ox/std/optional.hpp
									
									
									
									
										vendored
									
									
								
							| @@ -21,12 +21,12 @@ template<typename T, std::size_t buffSize = sizeof(T)> | |||||||
| class Optional { | class Optional { | ||||||
| 	private: | 	private: | ||||||
| 		T *m_ptr = nullptr; | 		T *m_ptr = nullptr; | ||||||
| 		char m_data[buffSize]; | 		char m_data[buffSize] = {}; | ||||||
|  |  | ||||||
| 	public: | 	public: | ||||||
| 		Optional() noexcept = default; | 		constexpr Optional() noexcept = default; | ||||||
|  |  | ||||||
| 		Optional(const Optional &other) { | 		constexpr Optional(const Optional &other) { | ||||||
| 			if (m_ptr) { | 			if (m_ptr) { | ||||||
| 				m_ptr->~T(); | 				m_ptr->~T(); | ||||||
| 			} | 			} | ||||||
| @@ -37,7 +37,7 @@ class Optional { | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		Optional(const Optional &&other) noexcept { | 		constexpr Optional(const Optional &&other) noexcept { | ||||||
| 			if (m_ptr) { | 			if (m_ptr) { | ||||||
| 				m_ptr->~T(); | 				m_ptr->~T(); | ||||||
| 			} | 			} | ||||||
| @@ -82,7 +82,7 @@ class Optional { | |||||||
| 			return m_ptr; | 			return m_ptr; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		Optional &operator=(const Optional &other) { | 		constexpr Optional &operator=(const Optional &other) { | ||||||
| 			if (this == &other) { | 			if (this == &other) { | ||||||
| 				return *this; | 				return *this; | ||||||
| 			} | 			} | ||||||
| @@ -97,7 +97,7 @@ class Optional { | |||||||
| 			return *this; | 			return *this; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		Optional &operator=(Optional &&other) noexcept { | 		constexpr Optional &operator=(Optional &&other) noexcept { | ||||||
| 			if (this == &other) { | 			if (this == &other) { | ||||||
| 				return *this; | 				return *this; | ||||||
| 			} | 			} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user