Thoth
A functional, expressive, asynchronous C++26 webdev library
Loading...
Searching...
No Matches
Thoth::Utils Namespace Reference

Classes

struct  Overloaded
 
struct  SharedInputView
 

Typedefs

template<class T , class Variant >
using FirstConvertibleVariant = std::variant_alternative_t< FindMatchIndex< T, Variant, std::is_convertible >(), Variant >
 
template<class T , class Variant >
using FirstEqualVariant = std::variant_alternative_t< FindMatchIndex< T, Variant, std::is_same >(), Variant >
 

Functions

std::optional< const std::string_view > Env (std::string_view envkey)
 Get variables from the ".env" file. Supports command execution and multiline.
 
std::optional< const std::u8string_view > Utf8Env (std::string_view envkey)
 Get variables from the ".env" file. Supports command execution and multiline.
 
template<auto V>
constexpr auto ToValue ()
 If the template parameter is a value, then returns it. If is a type then construct and returns it.
 
template<class T >
constexpr T ToValue ()
 If the template parameter is a value, then returns it. If is a type then construct and returns it.
 
template<class Ret , class Class , class... Args>
constexpr auto Const (Ret(Class::*ptr)(Args...) const)
 
template<class Ret , class Class , class... Args>
constexpr auto Mut (Ret(Class::*ptr)(Args...))
 
template<class Ret , class Class , class... Args>
constexpr auto ConstFn (Ret(Class::*ptr)(Args...) const)
 
template<class Ret , class Class , class... Args>
constexpr auto MutFn (Ret(Class::*ptr)(Args...))
 
template<class Opt , class Err >
constexpr std::expected< typename std::remove_cvref_t< Opt >::value_type, Err > ValueOr (Opt &&val, Err &&err)
 Monad friendly function to transform std::expected<std::optional<T>, Err> into std::expected<T, Err> with a given Err.
 
template<class Opt , class Err >
constexpr auto ValueOrHof (Err &&err)
 @hof{ValueOr}
 
template<bool Negate, class Pred , class Trans , class Val >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr std::expected< Val, std::invoke_result_t< Trans, Val > > S_CallIfErrorImpl (Pred &&pred, Trans &&trans, Val &&value)
 
template<class Pred , class Trans , class Val >
constexpr auto CallIfError (Pred &&pred, Trans &&trans, Val &&value)
 In the std::expected<Val, Err> context, returns the value if the predicate match, or the std::unexpected with transformation applied to the error otherwise.
 
template<auto Pred, class Trans , class Val >
constexpr auto CallIfError (Trans &&trans, Val &&val)
 In the std::expected<Val, Err> context, returns the value if the predicate match, or the std::unexpected with transformation applied to the error otherwise.
 
template<auto Pred, auto Trans, class Val >
constexpr auto CallIfError (Val &&val)
 In the std::expected<Val, Err> context, returns the value if the predicate match, or the std::unexpected with transformation applied to the error otherwise.
 
template<class Pred , class Trans , class Val >
constexpr auto CallIfErrorNot (Pred &&pred, Trans &&trans, Val &&value)
 In the std::expected<Val, Err> context, returns the value if the predicate doesn't match, or the std::unexpected with transformation applied to the error otherwise.
 
template<auto Pred, class Trans , class Val >
constexpr auto CallIfErrorNot (Trans &&trans, Val &&val)
 In the std::expected<Val, Err> context, returns the value if the predicate doesn't match, or the std::unexpected with transformation applied to the error otherwise.
 
template<auto Pred, auto Trans, class Val >
constexpr auto CallIfErrorNot (Val &&val)
 In the std::expected<Val, Err> context, returns the value if the predicate doesn't match, or the std::unexpected with transformation applied to the error otherwise.
 
template<class Pred , class Trans >
constexpr auto CallIfErrorHof (Pred &&pred, Trans &&trans)
 @hof{CallIfError}
 
template<auto Pred, class Trans >
constexpr auto CallIfErrorHof (Trans &&trans)
 @hof{CallIfError}
 
template<auto Pred, auto Trans>
constexpr auto CallIfErrorHof ()
 @hof{CallIfError}
 
template<class Pred , class Trans >
constexpr auto CallIfErrorNotHof (Pred &&pred, Trans &&trans)
 @hof{CallIfErrorNot}
 
template<auto Pred, class Trans >
constexpr auto CallIfErrorNotHof (Trans &&trans)
 @hof{CallIfErrorNot}
 
template<auto Pred, auto Trans>
constexpr auto CallIfErrorNotHof ()
 @hof{CallIfErrorNot}
 
template<bool Negate, class Pred , class Val >
requires std::predicate<Pred&, Val&>
constexpr bool S_TestIfImpl (Pred &&pred, Val &value)
 
template<bool Negate, class Pred , class Val , class Err >
requires std::predicate<Pred&, Val&>
constexpr std::expected< Val, std::decay_t< Err > > S_ErrorIfImpl (Pred &&pred, Val &&value, Err &&error)
 
template<class Pred , class Val , class Err >
constexpr auto ErrorIf (Pred &&pred, Val &&value, Err &&error)
 In a std::expected<Val, Err> context, transform an error into a value only if the predicate match.
 
template<auto Pred, class Val , class Err >
constexpr auto ErrorIf (Val &&value, Err &&error)
 In a std::expected<Val, Err> context, transform an error into a value only if the predicate match.
 
template<class Pred , class Val , class Err >
constexpr auto ErrorIfNot (Pred &&pred, Val &&value, Err &&error)
 In a std::expected<Val, Err> context, transform an error into a value only if the predicate doesn't match.
 
template<auto Pred, class Val , class Err >
constexpr auto ErrorIfNot (Val &&value, Err &&error)
 In a std::expected<Val, Err> context, transform an error into a value only if the predicate doesn't match.
 
template<class Pred , class Err >
constexpr auto ErrorIfHof (Pred &&pred, Err &&error)
 @hof{ErrorIf}
 
template<auto Pred, class Err >
constexpr auto ErrorIfHof (Err &&error)
 @hof{ErrorIf}
 
template<class Pred , class Err >
constexpr auto ErrorIfNotHof (Pred &&pred, Err &&error)
 @hof{ErrorIfNof}
 
template<auto Pred, class Err >
constexpr auto ErrorIfNotHof (Err &&error)
 @hof{ErrorIfNot}
 
template<bool Negate, class Pred , class Trans , class Val >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto S_TransformOptIfImpl (Pred &&pred, Trans &&trans, Val &&value) -> std::optional< std::invoke_result_t< Trans, Val > >
 
template<bool Negate, class Pred , class Trans , class Val , class Err >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto S_TransformExpIfImpl (Pred &&pred, Trans &&trans, Val &&value, Err &&error) -> std::expected< std::invoke_result_t< Trans, Val >, std::decay_t< Err > >
 
template<class Pred , class Trans , class Val >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto TransformOptIf (Pred &&pred, Trans &&trans, Val &&value)
 In the std::optional<Val> context, returns the transformation applied to the value if the predicate match, or std::nullopt otherwise.
 
template<auto Pred, class Trans , class Val >
requires std::predicate<decltype(Pred), Val&> && std::invocable<Trans, Val>
constexpr auto TransformOptIf (Trans &&trans, Val &&value)
 In the std::optional<Val> context, returns the transformation applied to the value if the predicate match, or std::nullopt otherwise.
 
template<auto Pred, auto Trans, class Val >
requires std::invocable<decltype(Trans), Val>
constexpr auto TransformOptIf (Val &&value)
 In the std::optional<Val> context, returns the transformation applied to the value if the predicate match, or std::nullopt otherwise.
 
template<class Pred , class Trans , class Val >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto TransformOptIfNot (Pred &&pred, Trans &&trans, Val &&value)
 In the std::optional<Val> context, returns the transformation applied to the value if the predicate doesn't match, or std::nullopt otherwise.
 
template<auto Pred, class Trans , class Val >
requires std::predicate<decltype(Pred), Val&> && std::invocable<Trans, Val>
constexpr auto TransformOptIfNot (Trans &&trans, Val &&value)
 In the std::optional<Val> context, returns the transformation applied to the value if the predicate doesn't match, or std::nullopt otherwise.
 
template<auto Pred, auto Trans, class Val >
requires std::invocable<decltype(Trans), Val>
constexpr auto TransformOptIfNot (Val &&value)
 In the std::optional<Val> context, returns the transformation applied to the value if the predicate doesn't match, or std::nullopt otherwise.
 
template<class Pred , class Trans >
constexpr auto TransformOptIfHof (Pred &&pred, Trans &&trans)
 @hof{TransformOptIf}
 
template<auto Pred, class Trans >
constexpr auto TransformOptIfHof (Trans &&trans)
 @hof{TransformOptIf}
 
template<auto Pred, auto Trans>
constexpr auto TransformOptIfHof ()
 @hof{TransformOptIf}
 
template<class Pred , class Trans >
constexpr auto TransformOptIfNotHof (Pred &&pred, Trans &&trans)
 @hof{TransformOptIfNot}
 
template<auto Pred, class Trans >
constexpr auto TransformOptIfNotHof (Trans &&trans)
 @hof{TransformOptIfNot}
 
template<auto Pred, auto Trans>
constexpr auto TransformOptIfNotHof ()
 @hof{TransformOptIfNot}
 
template<class Pred , class Trans , class Val , class Err >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto TransformExpIf (Pred &&pred, Trans &&trans, Val &&value, Err &&error)
 In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate match, or std::unexpected{ error } otherwise.
 
template<auto Pred, class Trans , class Val , class Err >
requires std::predicate<decltype(Pred), Val&> && std::invocable<Trans, Val>
constexpr auto TransformExpIf (Trans &&trans, Val &&value, Err &&error)
 In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate match, or std::unexpected{ error } otherwise.
 
template<auto Pred, auto Trans, class Val , class Err >
requires std::invocable<decltype(Trans), Val>
constexpr auto TransformExpIf (Val &&value, Err &&error)
 In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate match, or std::unexpected{ error } otherwise.
 
template<class Pred , class Trans , class Val , class Err >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto TransformExpIfNot (Pred &&pred, Trans &&trans, Val &&value, Err &&error)
 In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate doesn't match, or std::unexpected{ error } otherwise.
 
template<auto Pred, class Trans , class Val , class Err >
requires std::predicate<decltype(Pred), Val&> && std::invocable<Trans, Val>
constexpr auto TransformExpIfNot (Trans &&trans, Val &&value, Err &&error)
 In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate doesn't match, or std::unexpected{ error } otherwise.
 
template<auto Pred, auto Trans, class Val , class Err >
requires std::invocable<decltype(Trans), Val>
constexpr auto TransformExpIfNot (Val &&value, Err &&error)
 In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate doesn't match, or std::unexpected{ error } otherwise.
 
template<class Pred , class Trans , class Err >
constexpr auto TransformExpIfHof (Pred &&pred, Trans &&trans, Err &&error)
 @hof{TransformExpIf}
 
template<auto Pred, class Trans , class Err >
constexpr auto TransformExpIfHof (Trans &&trans, Err &&error)
 @hof{TransformExpIf}
 
template<auto Pred, auto Trans, class Err >
constexpr auto TransformExpIfHof (Err &&error)
 @hof{TransformExpIf}
 
template<class Pred , class Trans , class Err >
constexpr auto TransformExpIfNotHof (Pred &&pred, Trans &&trans, Err &&error)
 @hof{TransformExpIfNot}
 
template<auto Pred, class Trans , class Err >
constexpr auto TransformExpIfNotHof (Trans &&trans, Err &&error)
 @hof{TransformExpIfNot}
 
template<auto Pred, auto Trans, class Err >
constexpr auto TransformExpIfNotHof (Err &&error)
 @hof{TransformExpIfNot}
 
template<bool Negate, class Pred , class Val >
requires std::predicate<Pred&, Val&>
constexpr std::optional< std::remove_cvref_t< Val > > S_NulloptIfImpl (Pred &&pred, Val &&value)
 
template<class Pred , class Val >
constexpr auto NulloptIf (Pred &&pred, Val &&value)
 In a std::optional<T> context, transforms the value to std::nullopt if the predicate match.
 
template<auto Pred, class Val >
constexpr auto NulloptIf (Val &&value)
 In a std::optional<T> context, transforms the value to std::nullopt if the predicate match.
 
template<class Pred , class Val >
constexpr auto NulloptIfNot (Pred &&pred, Val &&value)
 In a std::optional<T> context, transforms the value to std::nullopt if the predicate doesn't match.
 
template<auto Pred, class Val >
constexpr auto NulloptIfNot (Val &&value)
 In a std::optional<T> context, transforms the value to std::nullopt if the predicate doesn't match.
 
template<class Pred >
constexpr auto NulloptIfHof (Pred &&pred)
 @hof{NulloptIf}
 
template<auto Pred>
constexpr auto NulloptIfHof ()
 @hof{NulloptIf}
 
template<class Pred >
constexpr auto NulloptIfNotHof (Pred &&pred)
 @hof{NulloptIfNot}
 
template<auto Pred>
constexpr auto NulloptIfNotHof ()
 @hof{NulloptIfNot}
 
template<std::ranges::input_range R, class F , class Acc , class Exp = std::iter_value_t<R>, class Val = Exp::value_type, class Err = Exp::error_type>
requires std::same_as<Exp, std::expected<Val, Err>> && std::invocable<F, Acc, Val> && std::same_as<Acc, std::invoke_result_t<F, Acc, Val>>
constexpr std::expected< std::remove_cvref_t< Acc >, std::remove_cvref_t< Err > > FoldWhileSuccess (R &&range, F &&callable, Acc &&initial={})
 fast fail foldr
 
template<class F , class Exp >
constexpr auto FoldWhileSuccessHof (F &&callable, Exp &&reducer={})
 @hof{FoldWhileSuccess}
 
template<class T , class F >
requires std::invocable<F, T>
constexpr auto Self (T &&val, F &&callable)
 
template<class F >
constexpr auto SelfHof (F &&callable)
 
constexpr void HashCombine (size_t &seed, const size_t v)
 
template<class T , class Variant , template< class, class > class Relation, std::size_t Index = 0>
consteval size_t FindMatchIndexImpl ()
 
template<class T , class Variant , template< class, class > class Relation>
consteval std::size_t FindMatchIndex ()
 

Typedef Documentation

◆ FirstConvertibleVariant

template<class T , class Variant >
using Thoth::Utils::FirstConvertibleVariant = typedef std::variant_alternative_t<FindMatchIndex<T, Variant, std::is_convertible>(), Variant>

◆ FirstEqualVariant

template<class T , class Variant >
using Thoth::Utils::FirstEqualVariant = typedef std::variant_alternative_t<FindMatchIndex<T, Variant, std::is_same>(), Variant>

Function Documentation

◆ CallIfError() [1/3]

template<class Pred , class Trans , class Val >
constexpr auto Thoth::Utils::CallIfError ( Pred &&  pred,
Trans &&  trans,
Val &&  value 
)
constexpr

In the std::expected<Val, Err> context, returns the value if the predicate match, or the std::unexpected with transformation applied to the error otherwise.

◆ CallIfError() [2/3]

template<auto Pred, class Trans , class Val >
constexpr auto Thoth::Utils::CallIfError ( Trans &&  trans,
Val &&  val 
)
constexpr

In the std::expected<Val, Err> context, returns the value if the predicate match, or the std::unexpected with transformation applied to the error otherwise.

◆ CallIfError() [3/3]

template<auto Pred, auto Trans, class Val >
constexpr auto Thoth::Utils::CallIfError ( Val &&  val)
constexpr

In the std::expected<Val, Err> context, returns the value if the predicate match, or the std::unexpected with transformation applied to the error otherwise.

◆ CallIfErrorHof() [1/3]

template<auto Pred, auto Trans>
constexpr auto Thoth::Utils::CallIfErrorHof ( )
constexpr

@hof{CallIfError}

◆ CallIfErrorHof() [2/3]

template<class Pred , class Trans >
constexpr auto Thoth::Utils::CallIfErrorHof ( Pred &&  pred,
Trans &&  trans 
)
constexpr

@hof{CallIfError}

◆ CallIfErrorHof() [3/3]

template<auto Pred, class Trans >
constexpr auto Thoth::Utils::CallIfErrorHof ( Trans &&  trans)
constexpr

@hof{CallIfError}

◆ CallIfErrorNot() [1/3]

template<class Pred , class Trans , class Val >
constexpr auto Thoth::Utils::CallIfErrorNot ( Pred &&  pred,
Trans &&  trans,
Val &&  value 
)
constexpr

In the std::expected<Val, Err> context, returns the value if the predicate doesn't match, or the std::unexpected with transformation applied to the error otherwise.

◆ CallIfErrorNot() [2/3]

template<auto Pred, class Trans , class Val >
constexpr auto Thoth::Utils::CallIfErrorNot ( Trans &&  trans,
Val &&  val 
)
constexpr

In the std::expected<Val, Err> context, returns the value if the predicate doesn't match, or the std::unexpected with transformation applied to the error otherwise.

◆ CallIfErrorNot() [3/3]

template<auto Pred, auto Trans, class Val >
constexpr auto Thoth::Utils::CallIfErrorNot ( Val &&  val)
constexpr

In the std::expected<Val, Err> context, returns the value if the predicate doesn't match, or the std::unexpected with transformation applied to the error otherwise.

◆ CallIfErrorNotHof() [1/3]

template<auto Pred, auto Trans>
constexpr auto Thoth::Utils::CallIfErrorNotHof ( )
constexpr

@hof{CallIfErrorNot}

◆ CallIfErrorNotHof() [2/3]

template<class Pred , class Trans >
constexpr auto Thoth::Utils::CallIfErrorNotHof ( Pred &&  pred,
Trans &&  trans 
)
constexpr

@hof{CallIfErrorNot}

◆ CallIfErrorNotHof() [3/3]

template<auto Pred, class Trans >
constexpr auto Thoth::Utils::CallIfErrorNotHof ( Trans &&  trans)
constexpr

@hof{CallIfErrorNot}

◆ Const()

template<class Ret , class Class , class... Args>
constexpr auto Thoth::Utils::Const ( Ret(Class::*)(Args...) const  ptr)
constexpr

◆ ConstFn()

template<class Ret , class Class , class... Args>
constexpr auto Thoth::Utils::ConstFn ( Ret(Class::*)(Args...) const  ptr)
constexpr

◆ Env()

std::optional< const std::string_view > Thoth::Utils::Env ( std::string_view  envkey)

Get variables from the ".env" file. Supports command execution and multiline.

# support comments
UNQUOTED=just the first word
SINGLE='everything between the \'s'
INTERPOLATED="everything between the \'s, but can use thigs like {whoami}"
MULTILINE='''
{can't call commands}
{
"name": "Connor O'Brian"
}
'''
MULTILINE="""
{echo same as before but can use commands"}
"""

◆ ErrorIf() [1/2]

template<class Pred , class Val , class Err >
constexpr auto Thoth::Utils::ErrorIf ( Pred &&  pred,
Val &&  value,
Err &&  error 
)
constexpr

In a std::expected<Val, Err> context, transform an error into a value only if the predicate match.

◆ ErrorIf() [2/2]

template<auto Pred, class Val , class Err >
constexpr auto Thoth::Utils::ErrorIf ( Val &&  value,
Err &&  error 
)
constexpr

In a std::expected<Val, Err> context, transform an error into a value only if the predicate match.

◆ ErrorIfHof() [1/2]

template<auto Pred, class Err >
constexpr auto Thoth::Utils::ErrorIfHof ( Err &&  error)
constexpr

@hof{ErrorIf}

◆ ErrorIfHof() [2/2]

template<class Pred , class Err >
constexpr auto Thoth::Utils::ErrorIfHof ( Pred &&  pred,
Err &&  error 
)
constexpr

@hof{ErrorIf}

◆ ErrorIfNot() [1/2]

template<class Pred , class Val , class Err >
constexpr auto Thoth::Utils::ErrorIfNot ( Pred &&  pred,
Val &&  value,
Err &&  error 
)
constexpr

In a std::expected<Val, Err> context, transform an error into a value only if the predicate doesn't match.

◆ ErrorIfNot() [2/2]

template<auto Pred, class Val , class Err >
constexpr auto Thoth::Utils::ErrorIfNot ( Val &&  value,
Err &&  error 
)
constexpr

In a std::expected<Val, Err> context, transform an error into a value only if the predicate doesn't match.

◆ ErrorIfNotHof() [1/2]

template<auto Pred, class Err >
constexpr auto Thoth::Utils::ErrorIfNotHof ( Err &&  error)
constexpr

@hof{ErrorIfNot}

◆ ErrorIfNotHof() [2/2]

template<class Pred , class Err >
constexpr auto Thoth::Utils::ErrorIfNotHof ( Pred &&  pred,
Err &&  error 
)
constexpr

@hof{ErrorIfNof}

◆ FindMatchIndex()

template<class T , class Variant , template< class, class > class Relation>
consteval std::size_t Thoth::Utils::FindMatchIndex ( )

◆ FindMatchIndexImpl()

template<class T , class Variant , template< class, class > class Relation, std::size_t Index = 0>
consteval size_t Thoth::Utils::FindMatchIndexImpl ( )

◆ FoldWhileSuccess()

template<std::ranges::input_range R, class F , class Acc , class Exp = std::iter_value_t<R>, class Val = Exp::value_type, class Err = Exp::error_type>
requires std::same_as<Exp, std::expected<Val, Err>> && std::invocable<F, Acc, Val> && std::same_as<Acc, std::invoke_result_t<F, Acc, Val>>
constexpr std::expected< std::remove_cvref_t< Acc >, std::remove_cvref_t< Err > > Thoth::Utils::FoldWhileSuccess ( R &&  range,
F &&  callable,
Acc &&  initial = {} 
)
constexpr

fast fail foldr

F -> Exp -> Exp -> Exp like reduce but with fast fail

◆ FoldWhileSuccessHof()

template<class F , class Exp >
constexpr auto Thoth::Utils::FoldWhileSuccessHof ( F &&  callable,
Exp &&  reducer = {} 
)
constexpr

@hof{FoldWhileSuccess}

◆ HashCombine()

constexpr void Thoth::Utils::HashCombine ( size_t &  seed,
const size_t  v 
)
constexpr

◆ Mut()

template<class Ret , class Class , class... Args>
constexpr auto Thoth::Utils::Mut ( Ret(Class::*)(Args...)  ptr)
constexpr

◆ MutFn()

template<class Ret , class Class , class... Args>
constexpr auto Thoth::Utils::MutFn ( Ret(Class::*)(Args...)  ptr)
constexpr

◆ NulloptIf() [1/2]

template<class Pred , class Val >
constexpr auto Thoth::Utils::NulloptIf ( Pred &&  pred,
Val &&  value 
)
constexpr

In a std::optional<T> context, transforms the value to std::nullopt if the predicate match.

◆ NulloptIf() [2/2]

template<auto Pred, class Val >
constexpr auto Thoth::Utils::NulloptIf ( Val &&  value)
constexpr

In a std::optional<T> context, transforms the value to std::nullopt if the predicate match.

◆ NulloptIfHof() [1/2]

template<auto Pred>
constexpr auto Thoth::Utils::NulloptIfHof ( )
constexpr

@hof{NulloptIf}

◆ NulloptIfHof() [2/2]

template<class Pred >
constexpr auto Thoth::Utils::NulloptIfHof ( Pred &&  pred)
constexpr

@hof{NulloptIf}

◆ NulloptIfNot() [1/2]

template<class Pred , class Val >
constexpr auto Thoth::Utils::NulloptIfNot ( Pred &&  pred,
Val &&  value 
)
constexpr

In a std::optional<T> context, transforms the value to std::nullopt if the predicate doesn't match.

◆ NulloptIfNot() [2/2]

template<auto Pred, class Val >
constexpr auto Thoth::Utils::NulloptIfNot ( Val &&  value)
constexpr

In a std::optional<T> context, transforms the value to std::nullopt if the predicate doesn't match.

◆ NulloptIfNotHof() [1/2]

template<auto Pred>
constexpr auto Thoth::Utils::NulloptIfNotHof ( )
constexpr

@hof{NulloptIfNot}

◆ NulloptIfNotHof() [2/2]

template<class Pred >
constexpr auto Thoth::Utils::NulloptIfNotHof ( Pred &&  pred)
constexpr

@hof{NulloptIfNot}

◆ S_CallIfErrorImpl()

template<bool Negate, class Pred , class Trans , class Val >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr std::expected< Val, std::invoke_result_t< Trans, Val > > Thoth::Utils::S_CallIfErrorImpl ( Pred &&  pred,
Trans &&  trans,
Val &&  value 
)
constexpr

◆ S_ErrorIfImpl()

template<bool Negate, class Pred , class Val , class Err >
requires std::predicate<Pred&, Val&>
constexpr std::expected< Val, std::decay_t< Err > > Thoth::Utils::S_ErrorIfImpl ( Pred &&  pred,
Val &&  value,
Err &&  error 
)
constexpr

◆ S_NulloptIfImpl()

template<bool Negate, class Pred , class Val >
requires std::predicate<Pred&, Val&>
constexpr std::optional< std::remove_cvref_t< Val > > Thoth::Utils::S_NulloptIfImpl ( Pred &&  pred,
Val &&  value 
)
constexpr

◆ S_TestIfImpl()

template<bool Negate, class Pred , class Val >
requires std::predicate<Pred&, Val&>
constexpr bool Thoth::Utils::S_TestIfImpl ( Pred &&  pred,
Val &  value 
)
constexpr

◆ S_TransformExpIfImpl()

template<bool Negate, class Pred , class Trans , class Val , class Err >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto Thoth::Utils::S_TransformExpIfImpl ( Pred &&  pred,
Trans &&  trans,
Val &&  value,
Err &&  error 
) -> std::expected<std::invoke_result_t<Trans, Val>, std::decay_t<Err>>
constexpr

◆ S_TransformOptIfImpl()

template<bool Negate, class Pred , class Trans , class Val >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto Thoth::Utils::S_TransformOptIfImpl ( Pred &&  pred,
Trans &&  trans,
Val &&  value 
) -> std::optional<std::invoke_result_t<Trans, Val>>
constexpr

◆ Self()

template<class T , class F >
requires std::invocable<F, T>
constexpr auto Thoth::Utils::Self ( T &&  val,
F &&  callable 
)
constexpr

◆ SelfHof()

template<class F >
constexpr auto Thoth::Utils::SelfHof ( F &&  callable)
constexpr

◆ ToValue() [1/2]

template<auto V>
constexpr auto Thoth::Utils::ToValue ( )
constexpr

If the template parameter is a value, then returns it. If is a type then construct and returns it.

◆ ToValue() [2/2]

template<class T >
constexpr T Thoth::Utils::ToValue ( )
constexpr

If the template parameter is a value, then returns it. If is a type then construct and returns it.

◆ TransformExpIf() [1/3]

template<class Pred , class Trans , class Val , class Err >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto Thoth::Utils::TransformExpIf ( Pred &&  pred,
Trans &&  trans,
Val &&  value,
Err &&  error 
)
constexpr

In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate match, or std::unexpected{ error } otherwise.

◆ TransformExpIf() [2/3]

template<auto Pred, class Trans , class Val , class Err >
requires std::predicate<decltype(Pred), Val&> && std::invocable<Trans, Val>
constexpr auto Thoth::Utils::TransformExpIf ( Trans &&  trans,
Val &&  value,
Err &&  error 
)
constexpr

In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate match, or std::unexpected{ error } otherwise.

◆ TransformExpIf() [3/3]

template<auto Pred, auto Trans, class Val , class Err >
requires std::invocable<decltype(Trans), Val>
constexpr auto Thoth::Utils::TransformExpIf ( Val &&  value,
Err &&  error 
)
constexpr

In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate match, or std::unexpected{ error } otherwise.

◆ TransformExpIfHof() [1/3]

template<auto Pred, auto Trans, class Err >
constexpr auto Thoth::Utils::TransformExpIfHof ( Err &&  error)
constexpr

@hof{TransformExpIf}

◆ TransformExpIfHof() [2/3]

template<class Pred , class Trans , class Err >
constexpr auto Thoth::Utils::TransformExpIfHof ( Pred &&  pred,
Trans &&  trans,
Err &&  error 
)
constexpr

@hof{TransformExpIf}

◆ TransformExpIfHof() [3/3]

template<auto Pred, class Trans , class Err >
constexpr auto Thoth::Utils::TransformExpIfHof ( Trans &&  trans,
Err &&  error 
)
constexpr

@hof{TransformExpIf}

◆ TransformExpIfNot() [1/3]

template<class Pred , class Trans , class Val , class Err >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto Thoth::Utils::TransformExpIfNot ( Pred &&  pred,
Trans &&  trans,
Val &&  value,
Err &&  error 
)
constexpr

In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate doesn't match, or std::unexpected{ error } otherwise.

◆ TransformExpIfNot() [2/3]

template<auto Pred, class Trans , class Val , class Err >
requires std::predicate<decltype(Pred), Val&> && std::invocable<Trans, Val>
constexpr auto Thoth::Utils::TransformExpIfNot ( Trans &&  trans,
Val &&  value,
Err &&  error 
)
constexpr

In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate doesn't match, or std::unexpected{ error } otherwise.

◆ TransformExpIfNot() [3/3]

template<auto Pred, auto Trans, class Val , class Err >
requires std::invocable<decltype(Trans), Val>
constexpr auto Thoth::Utils::TransformExpIfNot ( Val &&  value,
Err &&  error 
)
constexpr

In the std::expected<Val, Err> context, returns the transformation applied to the value if the predicate doesn't match, or std::unexpected{ error } otherwise.

◆ TransformExpIfNotHof() [1/3]

template<auto Pred, auto Trans, class Err >
constexpr auto Thoth::Utils::TransformExpIfNotHof ( Err &&  error)
constexpr

@hof{TransformExpIfNot}

◆ TransformExpIfNotHof() [2/3]

template<class Pred , class Trans , class Err >
constexpr auto Thoth::Utils::TransformExpIfNotHof ( Pred &&  pred,
Trans &&  trans,
Err &&  error 
)
constexpr

@hof{TransformExpIfNot}

◆ TransformExpIfNotHof() [3/3]

template<auto Pred, class Trans , class Err >
constexpr auto Thoth::Utils::TransformExpIfNotHof ( Trans &&  trans,
Err &&  error 
)
constexpr

@hof{TransformExpIfNot}

◆ TransformOptIf() [1/3]

template<class Pred , class Trans , class Val >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto Thoth::Utils::TransformOptIf ( Pred &&  pred,
Trans &&  trans,
Val &&  value 
)
constexpr

In the std::optional<Val> context, returns the transformation applied to the value if the predicate match, or std::nullopt otherwise.

◆ TransformOptIf() [2/3]

template<auto Pred, class Trans , class Val >
requires std::predicate<decltype(Pred), Val&> && std::invocable<Trans, Val>
constexpr auto Thoth::Utils::TransformOptIf ( Trans &&  trans,
Val &&  value 
)
constexpr

In the std::optional<Val> context, returns the transformation applied to the value if the predicate match, or std::nullopt otherwise.

◆ TransformOptIf() [3/3]

template<auto Pred, auto Trans, class Val >
requires std::invocable<decltype(Trans), Val>
constexpr auto Thoth::Utils::TransformOptIf ( Val &&  value)
constexpr

In the std::optional<Val> context, returns the transformation applied to the value if the predicate match, or std::nullopt otherwise.

◆ TransformOptIfHof() [1/3]

template<auto Pred, auto Trans>
constexpr auto Thoth::Utils::TransformOptIfHof ( )
constexpr

@hof{TransformOptIf}

◆ TransformOptIfHof() [2/3]

template<class Pred , class Trans >
constexpr auto Thoth::Utils::TransformOptIfHof ( Pred &&  pred,
Trans &&  trans 
)
constexpr

@hof{TransformOptIf}

◆ TransformOptIfHof() [3/3]

template<auto Pred, class Trans >
constexpr auto Thoth::Utils::TransformOptIfHof ( Trans &&  trans)
constexpr

@hof{TransformOptIf}

◆ TransformOptIfNot() [1/3]

template<class Pred , class Trans , class Val >
requires std::predicate<Pred&, Val&> && std::invocable<Trans, Val>
constexpr auto Thoth::Utils::TransformOptIfNot ( Pred &&  pred,
Trans &&  trans,
Val &&  value 
)
constexpr

In the std::optional<Val> context, returns the transformation applied to the value if the predicate doesn't match, or std::nullopt otherwise.

◆ TransformOptIfNot() [2/3]

template<auto Pred, class Trans , class Val >
requires std::predicate<decltype(Pred), Val&> && std::invocable<Trans, Val>
constexpr auto Thoth::Utils::TransformOptIfNot ( Trans &&  trans,
Val &&  value 
)
constexpr

In the std::optional<Val> context, returns the transformation applied to the value if the predicate doesn't match, or std::nullopt otherwise.

◆ TransformOptIfNot() [3/3]

template<auto Pred, auto Trans, class Val >
requires std::invocable<decltype(Trans), Val>
constexpr auto Thoth::Utils::TransformOptIfNot ( Val &&  value)
constexpr

In the std::optional<Val> context, returns the transformation applied to the value if the predicate doesn't match, or std::nullopt otherwise.

◆ TransformOptIfNotHof() [1/3]

template<auto Pred, auto Trans>
constexpr auto Thoth::Utils::TransformOptIfNotHof ( )
constexpr

@hof{TransformOptIfNot}

◆ TransformOptIfNotHof() [2/3]

template<class Pred , class Trans >
constexpr auto Thoth::Utils::TransformOptIfNotHof ( Pred &&  pred,
Trans &&  trans 
)
constexpr

@hof{TransformOptIfNot}

◆ TransformOptIfNotHof() [3/3]

template<auto Pred, class Trans >
constexpr auto Thoth::Utils::TransformOptIfNotHof ( Trans &&  trans)
constexpr

@hof{TransformOptIfNot}

◆ Utf8Env()

std::optional< const std::u8string_view > Thoth::Utils::Utf8Env ( std::string_view  envkey)

Get variables from the ".env" file. Supports command execution and multiline.

# support comments
UNQUOTED=just the first word
SINGLE='everything between the \'s'
INTERPOLATED="everything between the \'s, but can use thigs like {whoami}"
MULTILINE='''
{can't call commands}
{
"name": "Connor O'Brian"
}
'''
MULTILINE="""
{echo same as before but can use commands"}
"""

◆ ValueOr()

template<class Opt , class Err >
constexpr std::expected< typename std::remove_cvref_t< Opt >::value_type, Err > Thoth::Utils::ValueOr ( Opt &&  val,
Err &&  err 
)
constexpr

Monad friendly function to transform std::expected<std::optional<T>, Err> into std::expected<T, Err> with a given Err.

◆ ValueOrHof()

template<class Opt , class Err >
constexpr auto Thoth::Utils::ValueOrHof ( Err &&  err)
constexpr

@hof{ValueOr}