LeechCraft 0.6.70-17335-ge406ffdcaf
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
LC::Util::InstanceFunctor< std::optional< T > > Struct Template Reference

Implementation of the Functor class for std::optional. More...

#include "functor.h"

+ Inheritance diagram for LC::Util::InstanceFunctor< std::optional< T > >:
+ Collaboration diagram for LC::Util::InstanceFunctor< std::optional< T > >:

Public Types

template<typename F>
using FmapResult_t = std::optional<detail::WrapVoidResult_t<std::decay_t<std::invoke_result_t<F, T>>>>
 
using UndefinedTag
 
using FmapResult_t
 The type of the functor after its elements were mapped by the function F.
 

Static Public Member Functions

template<typename F>
static FmapResult_t< F > Apply (const std::optional< T > &t, const F &f)
 
static FmapResult_t< F > Apply (const T &functor, const F &function)
 Applies the function to the each of the elements inside the functor.
 

Detailed Description

template<typename T>
struct LC::Util::InstanceFunctor< std::optional< T > >

Implementation of the Functor class for std::optional.

The implementation applies the function to the contents of the std::optional if it's not empty, otherwise it just leaves an empty std::optional.

This is analogous to the Maybe type.

Template Parameters
TThe element type contained inside the std::optional.

Definition at line 214 of file functor.h.

Member Typedef Documentation

◆ FmapResult_t [1/2]

using LC::Util::InstanceFunctor< T >::FmapResult_t

The type of the functor after its elements were mapped by the function F.

This type should correspond to the return type of the Apply() function when passed this functor and a function of type F.

Template Parameters
FThe type of the function to apply to the elements inside this functor.

Definition at line 50 of file functor.h.

◆ FmapResult_t [2/2]

template<typename T>
template<typename F>
using LC::Util::InstanceFunctor< std::optional< T > >::FmapResult_t = std::optional<detail::WrapVoidResult_t<std::decay_t<std::invoke_result_t<F, T>>>>

Definition at line 217 of file functor.h.

◆ UndefinedTag

using LC::Util::InstanceFunctor< T >::UndefinedTag

Definition at line 37 of file functor.h.

Member Function Documentation

◆ Apply() [1/2]

template<typename T>
template<typename F>
static FmapResult_t< F > LC::Util::InstanceFunctor< std::optional< T > >::Apply ( const std::optional< T > & t,
const F & f )
inlinestatic

Definition at line 220 of file functor.h.

◆ Apply() [2/2]

static FmapResult_t< F > LC::Util::InstanceFunctor< T >::Apply ( const T & functor,
const F & function )
static

Applies the function to the each of the elements inside the functor.

Parameters
[in]functorThe functor whose values are subject to function.
[in]functionThe function that should be applied to the values in the functor.
Returns
A functor of type FmapResult_t<F> where each element the result of applying the function to the corresponding element in the source functor.
Template Parameters
FThe type of the function to apply to the elements in the function.

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