mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Replace boost::optional with std::optional where possible
This commit is contained in:
		
							parent
							
								
									87e16c80ac
								
							
						
					
					
						commit
						d37a2270d6
					
				
					 30 changed files with 104 additions and 106 deletions
				
			
		|  | @ -4,13 +4,14 @@ | |||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <functional> | ||||
| #include <memory> | ||||
| #include <mutex> | ||||
| #include <optional> | ||||
| #include <string> | ||||
| #include <thread> | ||||
| #include <tuple> | ||||
| #include <vector> | ||||
| #include <boost/optional.hpp> | ||||
| #include "common/common_types.h" | ||||
| #include "common/thread.h" | ||||
| #include "common/vector_math.h" | ||||
|  | @ -40,7 +41,7 @@ struct DeviceStatus { | |||
|         u16 max_x; | ||||
|         u16 max_y; | ||||
|     }; | ||||
|     boost::optional<CalibrationData> touch_calibration; | ||||
|     std::optional<CalibrationData> touch_calibration; | ||||
| }; | ||||
| 
 | ||||
| class Client { | ||||
|  |  | |||
|  | @ -29,24 +29,24 @@ namespace Response { | |||
|  * Note: Modifies the buffer to zero out the crc (since thats the easiest way to check without | ||||
|  * copying the buffer) | ||||
|  */ | ||||
| boost::optional<Type> Validate(u8* data, std::size_t size) { | ||||
| std::optional<Type> Validate(u8* data, std::size_t size) { | ||||
|     if (size < sizeof(Header)) { | ||||
|         LOG_DEBUG(Input, "Invalid UDP packet received"); | ||||
|         return boost::none; | ||||
|         return {}; | ||||
|     } | ||||
|     Header header; | ||||
|     std::memcpy(&header, data, sizeof(Header)); | ||||
|     if (header.magic != SERVER_MAGIC) { | ||||
|         LOG_ERROR(Input, "UDP Packet has an unexpected magic value"); | ||||
|         return boost::none; | ||||
|         return {}; | ||||
|     } | ||||
|     if (header.protocol_version != PROTOCOL_VERSION) { | ||||
|         LOG_ERROR(Input, "UDP Packet protocol mismatch"); | ||||
|         return boost::none; | ||||
|         return {}; | ||||
|     } | ||||
|     if (header.type < Type::Version || header.type > Type::PadData) { | ||||
|         LOG_ERROR(Input, "UDP Packet is an unknown type"); | ||||
|         return boost::none; | ||||
|         return {}; | ||||
|     } | ||||
| 
 | ||||
|     // Packet size must equal sizeof(Header) + sizeof(Data)
 | ||||
|  | @ -59,7 +59,7 @@ boost::optional<Type> Validate(u8* data, std::size_t size) { | |||
|             Input, | ||||
|             "UDP Packet payload length doesn't match. Received: {} PayloadLength: {} Expected: {}", | ||||
|             size, header.payload_length, data_len + sizeof(Type)); | ||||
|         return boost::none; | ||||
|         return {}; | ||||
|     } | ||||
| 
 | ||||
|     const u32 crc32 = header.crc; | ||||
|  | @ -70,7 +70,7 @@ boost::optional<Type> Validate(u8* data, std::size_t size) { | |||
|     result.process_bytes(data, data_len + sizeof(Header)); | ||||
|     if (crc32 != result.checksum()) { | ||||
|         LOG_ERROR(Input, "UDP Packet CRC check failed. Offset: {}", offsetof(Header, crc)); | ||||
|         return boost::none; | ||||
|         return {}; | ||||
|     } | ||||
|     return header.type; | ||||
| } | ||||
|  |  | |||
|  | @ -5,10 +5,10 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <array> | ||||
| #include <optional> | ||||
| #include <type_traits> | ||||
| #include <vector> | ||||
| #include <boost/crc.hpp> | ||||
| #include <boost/optional.hpp> | ||||
| #include "common/bit_field.h" | ||||
| #include "common/swap.h" | ||||
| 
 | ||||
|  | @ -218,7 +218,7 @@ static_assert(sizeof(Message<PadData>) == MAX_PACKET_SIZE, | |||
|  * @return boost::none if it failed to parse or Type if it succeeded. The client can then safely | ||||
|  * copy the data into the appropriate struct for that Type | ||||
|  */ | ||||
| boost::optional<Type> Validate(u8* data, std::size_t size); | ||||
| std::optional<Type> Validate(u8* data, std::size_t size); | ||||
| 
 | ||||
| } // namespace Response
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -42,7 +42,7 @@ public: | |||
|     std::unique_ptr<Input::TouchDevice> Create(const Common::ParamPackage& params) override { | ||||
|         { | ||||
|             std::lock_guard<std::mutex> guard(status->update_mutex); | ||||
|             status->touch_calibration.reset({}); | ||||
|             status->touch_calibration.reset(); | ||||
|             // These default values work well for DS4 but probably not other touch inputs
 | ||||
|             status->touch_calibration->min_x = params.Get("min_x", 100); | ||||
|             status->touch_calibration->min_y = params.Get("min_y", 50); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue