From 6ff95392b070e243f102ace34017205c95649150 Mon Sep 17 00:00:00 2001 From: jrkoonce <30676875+jrkoonce@users.noreply.github.com> Date: Wed, 4 Sep 2019 10:50:55 -0500 Subject: [PATCH] Fix Compiler Warnings --- tests/tester.cc | 2 +- tiny_gltf.h | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/tester.cc b/tests/tester.cc index d9d2dca..83187d1 100644 --- a/tests/tester.cc +++ b/tests/tester.cc @@ -20,7 +20,7 @@ TEST_CASE("parse-error", "[parse]") { std::string err; std::string warn; - bool ret = ctx.LoadASCIIFromString(&model, &err, &warn, "bora", strlen("bora"), /* basedir*/ ""); + bool ret = ctx.LoadASCIIFromString(&model, &err, &warn, "bora", static_cast(strlen("bora")), /* basedir*/ ""); REQUIRE(false == ret); diff --git a/tiny_gltf.h b/tiny_gltf.h index b8e1449..5b7e69b 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -1015,6 +1015,7 @@ struct Mesh { Value extras; Mesh() = default; + ~Mesh() = default; Mesh(const Mesh&) = default; Mesh(Mesh&& rhs) noexcept : name(std::move(rhs.name)) @@ -1022,6 +1023,14 @@ struct Mesh { , weights(std::move(rhs.weights)) , extensions(std::move(rhs.extensions)) , extras(std::move(rhs.extras)) {} + Mesh &operator=(const Mesh &) = default; + Mesh &operator=(Mesh &&rhs) { + if (&rhs != this) { + this->~Mesh(); + new (reinterpret_cast(this)) Mesh(std::move(rhs)); + } + return *this; + } bool operator==(const Mesh &) const; }; @@ -1062,6 +1071,13 @@ class Node { ~Node() {} Node &operator=(const Node &rhs) = default; + Node &operator=(Node &&rhs) { + if (&rhs != this) { + this->~Node(); + new (reinterpret_cast(this)) Node(std::move(rhs)); + } + return *this; + } bool operator==(const Node &) const; @@ -1107,6 +1123,7 @@ struct Asset { Value extras; Asset() = default; + ~Asset() = default; Asset(const Asset&) = default; Asset(Asset&& rhs) noexcept : version(std::move(rhs.version)) @@ -1115,6 +1132,14 @@ struct Asset { , copyright(std::move(rhs.copyright)) , extensions(std::move(rhs.extensions)) , extras(std::move(rhs.extras)) {} + Asset &operator=(const Asset &) = default; + Asset &operator=(Asset &&rhs) { + if (&rhs != this) { + this->~Asset(); + new (reinterpret_cast(this)) Asset(std::move(rhs)); + } + return *this; + } bool operator==(const Asset &) const; };