mirror of
https://github.com/Halofreak1990/XFXFramework
synced 2024-12-26 13:49:34 +01:00
Added implicit conversion to base types to all primary types (UInt32 et al) Added implicit conversion from System::String to const char*
38 lines
634 B
C++
38 lines
634 B
C++
|
|
namespace System
|
|
{
|
|
// Represents an object whose underlying type is a value type that can also be assigned null like a reference type.
|
|
template <typename T>
|
|
class Nullable
|
|
{
|
|
private:
|
|
T* data;
|
|
|
|
public:
|
|
static const Nullable<T> Null;
|
|
|
|
Nullable()
|
|
: data(null)
|
|
{
|
|
}
|
|
|
|
Nullable(const T& newData)
|
|
: data(const_cast<T*>(&newData))
|
|
{
|
|
}
|
|
|
|
Nullable(const Nullable<T> &obj)
|
|
: data(obj.data)
|
|
{
|
|
}
|
|
|
|
bool HasValue() const { return (data != null); }
|
|
T getValue() const { return *data; }
|
|
|
|
operator T() const { return *data; }
|
|
};
|
|
|
|
template <typename T>
|
|
const Nullable<T> Nullable<T>::Null = Nullable<T>();
|
|
}
|