Files
Ben Marsh cda1b66bba Reformat EpicGames.Core according to standard coding conventions.
#preflight 623cd2e84368f558e30b4a9e

[CL 19502309 by Ben Marsh in ue5-main branch]
2022-03-24 16:35:00 -04:00

50 lines
1.0 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
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)
{
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);
}
}
}