diff --git a/code/Common/Maybe.h b/code/Common/Maybe.h index b23865b86..387c1bcaf 100644 --- a/code/Common/Maybe.h +++ b/code/Common/Maybe.h @@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include +#include namespace Assimp { @@ -48,13 +49,14 @@ namespace Assimp { /// @tparam T The type to store. template struct Maybe { - /// @brief + /// @brief Maybe() = default; - /// @brief - /// @param val - explicit Maybe(const T &val) : - _val(val), _valid(true) {} + /// @brief + /// @param val + template + explicit Maybe(U &&val) : + _val(std::forward(val)), _valid(true) {} /// @brief Validate the value /// @return true if valid. @@ -64,11 +66,12 @@ struct Maybe { /// @brief Will assign a value. /// @param v The new valid value. - void Set(T &v) { + template + void Set(U &&v) { ai_assert(!_valid); _valid = true; - _val = v; + _val = std::forward(v); } /// @brief Will return the value when it is valid.