MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Mcro::Error::TMaybe< T > Struct Template Reference

#include <Error.h>

Public Types

using ValueType = T
 

Public Member Functions

template<typename = T>
requires (!CDefaultInitializable<T>)
 TMaybe ()
 
template<CDefaultInitializable = T>
 TMaybe ()
 
template<CConvertibleToDecayed< T > From, CCopyConstructible = T>
 TMaybe (From const &value)
 
template<CConvertibleToDecayed< T > From, CMoveConstructible = T>
 TMaybe (From &&value)
 
template<CConvertibleToDecayed< T > From, CCopyConstructible = T>
 TMaybe (TMaybe< From > const &other)
 
template<CConvertibleToDecayed< T > From, CMoveConstructible = T>
 TMaybe (TMaybe< From > &&other)
 
template<CError ErrorType>
 TMaybe (TSharedRef< ErrorType > const &error)
 
bool HasValue () const
 
bool HasError () const
 
auto TryGetValue () -> TOptional< T > &
 
auto TryGetValue () const -> TOptional< T > const &
 
auto GetValue () -> T &
 
auto GetValue () const -> T const &
 
auto GetError () const -> IErrorPtr
 
 operator bool () const
 
 operator TValueOrError< T, IErrorPtr > () const
 

Detailed Description

template<CNonVoid T>
struct Mcro::Error::TMaybe< T >

A TValueOrError alternative for IError which allows implicit conversion from values and errors (no need for MakeError or MakeValue) and is boolean testable. It also doesn't have ambiguous state such as TValueOrError has, so a TMaybe will always have either an error or a value, it will never have neither of them or both of them.

Definition at line 514 of file Error.h.

Member Typedef Documentation

◆ ValueType

template<CNonVoid T>
using Mcro::Error::TMaybe< T >::ValueType = T

Definition at line 516 of file Error.h.

Constructor & Destructor Documentation

◆ TMaybe() [1/7]

template<CNonVoid T>
template<typename = T>
requires (!CDefaultInitializable<T>)
Mcro::Error::TMaybe< T >::TMaybe ( )
inline

Default initializing a TMaybe while its value is not default initializable, initializes the resulting TMaybe to an erroneous state.

Definition at line 524 of file Error.h.

◆ TMaybe() [2/7]

template<CNonVoid T>
template<CDefaultInitializable = T>
Mcro::Error::TMaybe< T >::TMaybe ( )
inline

If T is default initializable then the default state of TMaybe will be the default value of T, and not an error

Definition at line 533 of file Error.h.

◆ TMaybe() [3/7]

template<CNonVoid T>
template<CConvertibleToDecayed< T > From, CCopyConstructible = T>
Mcro::Error::TMaybe< T >::TMaybe ( From const & value)
inline

Enable copy constructor for T only when T is copy constructable

Definition at line 537 of file Error.h.

◆ TMaybe() [4/7]

template<CNonVoid T>
template<CConvertibleToDecayed< T > From, CMoveConstructible = T>
Mcro::Error::TMaybe< T >::TMaybe ( From && value)
inline

Enable move constructor for T only when T is move constructable

Definition at line 541 of file Error.h.

◆ TMaybe() [5/7]

template<CNonVoid T>
template<CConvertibleToDecayed< T > From, CCopyConstructible = T>
Mcro::Error::TMaybe< T >::TMaybe ( TMaybe< From > const & other)
inline

Enable copy constructor for TMaybe only when T is copy constructable

Definition at line 545 of file Error.h.

◆ TMaybe() [6/7]

template<CNonVoid T>
template<CConvertibleToDecayed< T > From, CMoveConstructible = T>
Mcro::Error::TMaybe< T >::TMaybe ( TMaybe< From > && other)
inline

Enable move constructor for TMaybe only when T is move constructable

Definition at line 549 of file Error.h.

◆ TMaybe() [7/7]

template<CNonVoid T>
template<CError ErrorType>
Mcro::Error::TMaybe< T >::TMaybe ( TSharedRef< ErrorType > const & error)
inline

Set this TMaybe to an erroneous state

Definition at line 553 of file Error.h.

Member Function Documentation

◆ GetError()

template<CNonVoid T>
auto Mcro::Error::TMaybe< T >::GetError ( ) const -> IErrorPtr
inline

Definition at line 564 of file Error.h.

◆ GetValue() [1/2]

template<CNonVoid T>
auto Mcro::Error::TMaybe< T >::GetValue ( ) -> T&
inline

Definition at line 561 of file Error.h.

◆ GetValue() [2/2]

template<CNonVoid T>
auto Mcro::Error::TMaybe< T >::GetValue ( ) const -> T const&
inline

Definition at line 562 of file Error.h.

◆ HasError()

template<CNonVoid T>
bool Mcro::Error::TMaybe< T >::HasError ( ) const
inline

Definition at line 556 of file Error.h.

◆ HasValue()

template<CNonVoid T>
bool Mcro::Error::TMaybe< T >::HasValue ( ) const
inline

Definition at line 555 of file Error.h.

◆ operator bool()

template<CNonVoid T>
Mcro::Error::TMaybe< T >::operator bool ( ) const
inline

Definition at line 566 of file Error.h.

◆ operator TValueOrError< T, IErrorPtr >()

template<CNonVoid T>
Mcro::Error::TMaybe< T >::operator TValueOrError< T, IErrorPtr > ( ) const
inline

Definition at line 568 of file Error.h.

◆ TryGetValue() [1/2]

template<CNonVoid T>
auto Mcro::Error::TMaybe< T >::TryGetValue ( ) -> TOptional<T>&
inline

Definition at line 558 of file Error.h.

◆ TryGetValue() [2/2]

template<CNonVoid T>
auto Mcro::Error::TMaybe< T >::TryGetValue ( ) const -> TOptional<T> const&
inline

Definition at line 559 of file Error.h.


The documentation for this struct was generated from the following file: