FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
Value< T, E > Struct Template Reference

Enhanced expected type with integrated logging capabilities. More...

#include <expected.hpp>

Inheritance diagram for Value< T, E >:
[legend]
Collaboration diagram for Value< T, E >:
[legend]

Public Member Functions

template<ns_string::static_string fmt = "Q::", typename... Args>
void discard_impl (ns_log::Location const &loc, Args &&... args)
 Log error and discard it if present.
 
template<ns_string::static_string fmt = "Q::", typename... Args>
Value< T, E > forward_impl (ns_log::Location const &loc, Args &&... args)
 Forward error with logging or return value.
 
or_default ()
 

Detailed Description

template<typename T, typename E = std::string>
struct Value< T, E >

Enhanced expected type with integrated logging capabilities.

Value extends std::expected to provide automatic error logging and convenient error handling methods. It maintains full compatibility with std::expected while adding FlatImage-specific functionality.

Template Parameters
TThe expected value type (can be void)
EThe error type (defaults to std::string)
Note
Inherits all std::expected constructors and methods
See also
std::expected
Examples
/flatimage/src/filesystems/layers.hpp, and /flatimage/src/std/expected.hpp.

Definition at line 43 of file expected.hpp.

Member Function Documentation

◆ discard_impl()

template<typename T, typename E = std::string>
template<ns_string::static_string fmt = "Q::", typename... Args>
void Value< T, E >::discard_impl ( ns_log::Location const & loc,
Args &&... args )
inline

Log error and discard it if present.

If this Value contains an error, logs it at the specified level along with any additional context, then continues execution.

Template Parameters
fmtFormat string with log level prefix (D::, I::, W::, E::, C::)
ArgsTypes of additional format arguments
Parameters
locSource location for logging
argsAdditional arguments for the format string
Note
Used internally by the discard() macro
Examples
/flatimage/src/std/expected.hpp.

Definition at line 87 of file expected.hpp.

◆ forward_impl()

template<typename T, typename E = std::string>
template<ns_string::static_string fmt = "Q::", typename... Args>
Value< T, E > Value< T, E >::forward_impl ( ns_log::Location const & loc,
Args &&... args )
inline

Forward error with logging or return value.

If this Value contains an error, logs it and returns a new Value with the same error. Otherwise, returns a Value with the contained value.

Template Parameters
fmtFormat string with log level prefix
ArgsTypes of additional format arguments
Parameters
locSource location for logging
argsAdditional arguments for the format string
Returns
Value<T,E> Forwarded Value with same state
Note
Used internally by the forward() macro
Examples
/flatimage/src/std/expected.hpp.

Definition at line 111 of file expected.hpp.

◆ or_default()

template<typename T, typename E = std::string>
T Value< T, E >::or_default ( )
inline
Examples
/flatimage/src/std/expected.hpp.

Definition at line 134 of file expected.hpp.


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