Skip to content

Class endstone::Preconditions

ClassList > endstone > Preconditions

Static helpers for validating method arguments and object state.

  • #include <endstone/check.h>

Public Static Functions

Type Name
void checkArgument (bool condition, std::format_string< Args... > format, Args &&... args)
Ensures the truth of an expression involving one or more parameters to the calling method.
void checkState (bool condition, std::format_string< Args... > format, Args &&... args)
Ensures the truth of an expression involving the state of the calling instance.

Public Static Functions Documentation

function checkArgument

Ensures the truth of an expression involving one or more parameters to the calling method.

template<typename... Args>
static inline void endstone::Preconditions::checkArgument (
    bool condition,
    std::format_string< Args... > format,
    Args &&... args
) 

Parameters:

  • condition The expression that must hold.
  • format A format string describing the failure, used when the condition is false.
  • args Arguments to substitute into the format string.

Exception:

  • std::invalid_argument if condition is false.

function checkState

Ensures the truth of an expression involving the state of the calling instance.

template<typename... Args>
static inline void endstone::Preconditions::checkState (
    bool condition,
    std::format_string< Args... > format,
    Args &&... args
) 

Parameters:

  • condition The expression that must hold.
  • format A format string describing the failure, used when the condition is false.
  • args Arguments to substitute into the format string.

Exception:

  • std::runtime_error if condition is false.


The documentation for this class was generated from the following file include/endstone/check.h