From 504a62ead8b2eee7b165698e4c56cc484f93e295 Mon Sep 17 00:00:00 2001 From: Rich Logan Date: Mon, 6 Nov 2023 14:26:26 +0000 Subject: [PATCH] Add default equality operators --- include/gs_types.h | 56 ++++++++++++++++++++++-- src/CMakeLists.txt | 2 +- test/test_databuffer/CMakeLists.txt | 2 +- test/test_float/CMakeLists.txt | 2 +- test/test_gs_api/CMakeLists.txt | 2 +- test/test_gs_decoder/CMakeLists.txt | 2 +- test/test_gs_deserializer/CMakeLists.txt | 2 +- test/test_gs_encoder/CMakeLists.txt | 2 +- test/test_gs_serializer/CMakeLists.txt | 2 +- test/test_half_float/CMakeLists.txt | 2 +- 10 files changed, 62 insertions(+), 12 deletions(-) diff --git a/include/gs_types.h b/include/gs_types.h index 44c5e3d..91d2c14 100644 --- a/include/gs_types.h +++ b/include/gs_types.h @@ -59,9 +59,27 @@ namespace gs { // Primitive types - struct VarUint { std::uint64_t value; }; - struct VarInt { std::int64_t value; }; - struct Float16 { float value; }; + struct VarUint + { + std::uint64_t value; + + auto operator<=>(const VarUint &other) const = default; + }; + + struct VarInt + { + std::int64_t value; + + auto operator<=>(const VarInt &other) const = default; + }; + + struct Float16 + { + float value; + + auto operator<=>(const Float16 &other) const = default; + }; + typedef float Float32; typedef double Float64; typedef std::uint8_t Uint8; @@ -104,6 +122,8 @@ namespace gs Float32 x; Float32 y; Float32 z; + + auto operator<=>(const Loc1 &other) const = default; }; struct Loc2 @@ -114,6 +134,8 @@ namespace gs Float16 vy; Float16 vx; Float16 vz; + + auto operator<=>(const Loc2 &other) const = default; }; struct Norm1 @@ -121,12 +143,16 @@ namespace gs Float16 x; Float16 y; Float16 z; + + auto operator<=>(const Norm1 &other) const = default; }; struct TextureUV1 { VarUint u; VarUint v; + + auto operator<=>(const TextureUV1 &other) const = default; }; struct Rot1 @@ -134,6 +160,8 @@ namespace gs Float16 i; Float16 j; Float16 k; + + auto operator<=>(const Rot1 &other) const = default; }; struct Rot2 @@ -144,6 +172,8 @@ namespace gs Float16 ei; Float16 ej; Float16 ek; + + auto operator<=>(const Rot2 &other) const = default; }; struct Transform1 @@ -151,6 +181,8 @@ namespace gs Float16 tx; Float16 ty; Float16 tz; + + auto operator<=>(const Transform1 &other) const = default; }; struct Object1 @@ -162,11 +194,15 @@ namespace gs Loc1 scale; Boolean active; std::optional parent; + + bool operator==(const Object1 &other) const = default; }; struct HeadIPD1 { Float16 ipd; + + auto operator<=>(const HeadIPD1 &other) const = default; }; struct Head1 @@ -176,6 +212,8 @@ namespace gs Loc2 location; Rot2 rotation; std::optional ipd; + + bool operator==(const Head1 &other) const = default; }; struct Mesh1 @@ -185,6 +223,8 @@ namespace gs std::vector normals; std::vector textures; std::vector triangles; + + bool operator==(const Mesh1 &other) const = default; }; struct Hand1 @@ -194,6 +234,8 @@ namespace gs Boolean left; Loc2 location; Rot2 rotation; + + auto operator<=>(const Hand1 &other) const = default; }; struct Thumb @@ -202,6 +244,8 @@ namespace gs Transform1 ip; Transform1 mcp; Transform1 cmc; + + auto operator<=>(const Thumb &other) const = default; }; struct Finger @@ -211,6 +255,8 @@ namespace gs Transform1 pip; Transform1 mcp; Transform1 cmc; + + auto operator<=>(const Finger &other) const = default; }; struct Hand2 @@ -226,12 +272,16 @@ namespace gs Finger middle; Finger ring; Finger pinky; + + auto operator<=>(const Hand2 &other) const = default; }; struct UnknownObject { VarUint tag; Blob data; + + bool operator==(const UnknownObject &other) const = default; }; // Variant type that can contain any object type diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index beb107c..78b8a58 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,7 +11,7 @@ add_library(gse set_target_properties(gse PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO) target_compile_options(gse PRIVATE diff --git a/test/test_databuffer/CMakeLists.txt b/test/test_databuffer/CMakeLists.txt index cd2b4f1..5e00889 100644 --- a/test/test_databuffer/CMakeLists.txt +++ b/test/test_databuffer/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(test_databuffer test_databuffer.cpp) set_target_properties(test_databuffer PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO) diff --git a/test/test_float/CMakeLists.txt b/test/test_float/CMakeLists.txt index 78e3103..315ef52 100644 --- a/test/test_float/CMakeLists.txt +++ b/test/test_float/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(test_float test_float.cpp) set_target_properties(test_float PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO) diff --git a/test/test_gs_api/CMakeLists.txt b/test/test_gs_api/CMakeLists.txt index 38cdbc4..6415b46 100644 --- a/test/test_gs_api/CMakeLists.txt +++ b/test/test_gs_api/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(test_gs_api test_gs_api.cpp) set_target_properties(test_gs_api PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO) diff --git a/test/test_gs_decoder/CMakeLists.txt b/test/test_gs_decoder/CMakeLists.txt index b3a297d..6bee411 100644 --- a/test/test_gs_decoder/CMakeLists.txt +++ b/test/test_gs_decoder/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(test_gs_decoder test_gs_decoder.cpp) set_target_properties(test_gs_decoder PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO) diff --git a/test/test_gs_deserializer/CMakeLists.txt b/test/test_gs_deserializer/CMakeLists.txt index 4c9f7c6..a7b801b 100644 --- a/test/test_gs_deserializer/CMakeLists.txt +++ b/test/test_gs_deserializer/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(test_gs_deserializer test_gs_deserializer.cpp) set_target_properties(test_gs_deserializer PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO) diff --git a/test/test_gs_encoder/CMakeLists.txt b/test/test_gs_encoder/CMakeLists.txt index c8f8622..277817a 100644 --- a/test/test_gs_encoder/CMakeLists.txt +++ b/test/test_gs_encoder/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(test_gs_encoder test_gs_encoder.cpp) set_target_properties(test_gs_encoder PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO) diff --git a/test/test_gs_serializer/CMakeLists.txt b/test/test_gs_serializer/CMakeLists.txt index 2c1bd8a..c657dd5 100644 --- a/test/test_gs_serializer/CMakeLists.txt +++ b/test/test_gs_serializer/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(test_gs_serializer test_gs_serializer.cpp) set_target_properties(test_gs_serializer PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO) diff --git a/test/test_half_float/CMakeLists.txt b/test/test_half_float/CMakeLists.txt index 87d46f0..45dbc39 100644 --- a/test/test_half_float/CMakeLists.txt +++ b/test/test_half_float/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(test_half_float test_half_float.cpp) set_target_properties(test_half_float PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO)