You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
54 lines
1.1 KiB
C#
54 lines
1.1 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace EpicGames.Core
|
|
{
|
|
/// <summary>
|
|
/// Explicitly boxes a value type, allowing it to be passed by reference to (and modified in) an async method.
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
public class Boxed<T>
|
|
{
|
|
/// <summary>
|
|
/// The struct value
|
|
/// </summary>
|
|
public T Value { get; set; }
|
|
|
|
/// <summary>
|
|
/// Default constructor
|
|
/// </summary>
|
|
/// <param name="Value">The value to copy</param>
|
|
public Boxed(T Value)
|
|
{
|
|
this.Value = Value;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override string? ToString()
|
|
{
|
|
return Value?.ToString();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Implicit conversion of a boxed value to value type
|
|
/// </summary>
|
|
/// <param name="Boxed"></param>
|
|
public static implicit operator T(Boxed<T> Boxed)
|
|
{
|
|
return Boxed.Value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Implicit conversion of a boxed value to value type
|
|
/// </summary>
|
|
/// <param name="Value"></param>
|
|
public static implicit operator Boxed<T>(T Value)
|
|
{
|
|
return new Boxed<T>(Value);
|
|
}
|
|
}
|
|
}
|