From 06cf7326aeb5763d87f400cb75c576cb9d5463af Mon Sep 17 00:00:00 2001 From: sean Date: Sun, 10 Nov 2024 00:02:11 +0100 Subject: [PATCH] Add: Conversion ops for custom Optional class --- include/fastgltf/types.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/fastgltf/types.hpp b/include/fastgltf/types.hpp index 51d94fa18..4c7e5dcdc 100644 --- a/include/fastgltf/types.hpp +++ b/include/fastgltf/types.hpp @@ -1313,6 +1313,14 @@ namespace fastgltf { const T&& operator*() const&& noexcept { return std::move(_value); } + + operator std::optional() const noexcept { + return has_value() ? std::optional(_value) : std::nullopt; + } + + operator std::optional&&()&& noexcept { + return has_value() ? std::optional(std::move(_value)) : std::nullopt; + } }; FASTGLTF_EXPORT template