Merge pull request #4717 from Skylion007/perfect-forward-utMaybe

Perfect forward val to utMaybe.cpp
pull/4721/head
Kim Kulling 2022-09-12 10:15:03 +02:00 committed by GitHub
commit 7be7e5d93e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 7 deletions

View File

@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once
#include <assimp/ai_assert.h>
#include <utility>
namespace Assimp {
@ -53,8 +54,9 @@ struct Maybe {
/// @brief
/// @param val
explicit Maybe(const T &val) :
_val(val), _valid(true) {}
template <typename U>
explicit Maybe(U &&val) :
_val(std::forward<U>(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 <typename U>
void Set(U &&v) {
ai_assert(!_valid);
_valid = true;
_val = v;
_val = std::forward<U>(v);
}
/// @brief Will return the value when it is valid.