MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Mcro::Once::FOnce Struct Reference

#include <Once.h>

Public Member Functions

FORCEINLINE FOnce ()
 
FORCEINLINE FOnce (const FOnce &from)
 
FORCEINLINE FOnce (FOnce &&from) noexcept
 
FORCEINLINE operator bool ()
 
FORCEINLINE bool IsTriggered () const
 
FORCEINLINE void Reset ()
 

Detailed Description

Used for lambdas which supposed to run only once. The first time it is converted to bool it returns true
but every other times it will return false.

Usage:

using namespace BaseUtils;
SomeEvent.AddLambda([once = FOnce()]
{
    // Just use it inside a condition
    if (once) { ... }

    // exploiting short-circuit:
    if (MyCondition && once) { ... }

    // but this will not produce the expected result:
    if (once && MyCondition) { ... } // BAD
}

Definition at line 38 of file Once.h.

Constructor & Destructor Documentation

◆ FOnce() [1/3]

FORCEINLINE Mcro::Once::FOnce::FOnce ( )
inline

Definition at line 44 of file Once.h.

◆ FOnce() [2/3]

FORCEINLINE Mcro::Once::FOnce::FOnce ( const FOnce & from)
inline

Definition at line 45 of file Once.h.

◆ FOnce() [3/3]

FORCEINLINE Mcro::Once::FOnce::FOnce ( FOnce && from)
inlinenoexcept

Definition at line 46 of file Once.h.

Member Function Documentation

◆ IsTriggered()

FORCEINLINE bool Mcro::Once::FOnce::IsTriggered ( ) const
inline

Definition at line 58 of file Once.h.

◆ operator bool()

FORCEINLINE Mcro::Once::FOnce::operator bool ( )
inline

Definition at line 51 of file Once.h.

◆ Reset()

FORCEINLINE void Mcro::Once::FOnce::Reset ( )
inline

Definition at line 63 of file Once.h.


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