Skip to content

Commit

Permalink
Perfect forward val to utMaybe
Browse files Browse the repository at this point in the history
  • Loading branch information
Skylion007 committed Sep 9, 2022
1 parent 9519a62 commit 6bfc929
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions code/Common/Maybe.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once

#include <assimp/ai_assert.h>
#include <utility>

namespace Assimp {

/// @brief This class implements an optional type
/// @tparam T The type to store.
template <typename T>
struct Maybe {
/// @brief
/// @brief
Maybe() = default;

/// @brief
/// @param val
explicit Maybe(const T &val) :
_val(val), _valid(true) {}
/// @brief
/// @param val
template <typename U>
explicit Maybe(U &&val) :
_val(std::forward<U>(val)), _valid(true) {}

/// @brief Validate the value
/// @return true if valid.
Expand All @@ -64,11 +66,11 @@ struct Maybe {

/// @brief Will assign a value.
/// @param v The new valid value.
void Set(T &v) {
void Set(T &&v) {
ai_assert(!_valid);

_valid = true;
_val = v;
_val = std::forward<T>(v);
}

/// @brief Will return the value when it is valid.
Expand Down

0 comments on commit 6bfc929

Please sign in to comment.