Skip to content

Commit

Permalink
Add: Conversion ops for custom Optional class
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed Nov 9, 2024
1 parent 5278229 commit 06cf732
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/fastgltf/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,14 @@ namespace fastgltf {
const T&& operator*() const&& noexcept {
return std::move(_value);
}

operator std::optional<T>() const noexcept {
return has_value() ? std::optional<T>(_value) : std::nullopt;
}

operator std::optional<T>&&()&& noexcept {
return has_value() ? std::optional<T>(std::move(_value)) : std::nullopt;
}
};

FASTGLTF_EXPORT template <typename T, typename U>
Expand Down

0 comments on commit 06cf732

Please sign in to comment.