 |
LeechCraft
0.6.70-13605-g8cd066ad6a
Modular cross-platform feature rich live environment.
|
Go to the documentation of this file.
34 #include <boost/optional.hpp>
56 struct InstanceFunctor
88 static FmapResult_t<F>
Apply (
const T& functor,
const F&
function);
115 return detail::IsFunctorImpl<T> (0);
125 template<
typename T,
typename F>
126 using FmapResult_t =
typename InstanceFunctor<T>::template FmapResult_t<F>;
148 template<typename T, typename F, typename = std::enable_if_t<IsFunctor<T> ()>>
174 template<
typename T,
typename F>
175 auto operator* (
const F&
function,
const T& functor) -> decltype (
Fmap (functor,
function))
177 return Fmap (functor,
function);
200 template<
typename T,
typename F>
201 auto operator* (
const T& functor,
const F&
function) -> decltype (
Fmap (functor,
function))
203 return Fmap (functor,
function);
209 struct WrapVoidResult
215 struct WrapVoidResult<void>
235 struct InstanceFunctor<
boost::optional<T>>
241 static FmapResult_t<F>
Apply (
const boost::optional<T>& t,
const F&
f)
246 if constexpr (std::is_same_v<FmapResult_t<F>, boost::optional<Void>>)
252 return { std::invoke (
f, *t) };
257 struct InstanceFunctor<std::optional<T>>
274 return { std::invoke (
f, *t) };
detail::ImplementationType FmapResult_t
The type of the functor after its elements were mapped by the function F.
static FmapResult_t< F > Apply(const T &functor, const F &function)
Applies the function to the each of the elements inside the functor.
typename InstanceFunctor< T >::template FmapResult_t< F > FmapResult_t
The result type of the contents of the functor T mapped by function F.
constexpr bool IsFunctorImpl(int, typename InstanceFunctor< T >::UndefinedTag *=nullptr)
FmapResult_t< T, F > Fmap(const T &functor, const F &function)
Apply the function f to the elements in functor.
auto operator*(const AF &af, const AV &av) -> decltype(GSL(af, av))
typename WrapVoidResult< T >::Type WrapVoidResult_t
constexpr bool IsFunctor()
Checks whether the given type has a Functor instance for it.
constexpr detail::ExprTree< detail::ExprType::LeafStaticPlaceholder, detail::MemberPtrs< Ptr > > f
A proper void type, akin to unit (or ()) type in functional languages.