Krita Source Code Documentation
Loading...
Searching...
No Matches
kislager Namespace Reference

Namespaces

namespace  lenses
 

Functions

template<typename Func , typename... Cursors, typename FirstCursor = typename kismpl::first_type_t<std::remove_reference_t<Cursors>...>::value_type, typename T = typename FirstCursor::value_type>
std::optional< lager::reader< T > > fold_optional_cursors (const Func &func, Cursors &&...cursors)
 

Function Documentation

◆ fold_optional_cursors()

template<typename Func , typename... Cursors, typename FirstCursor = typename kismpl::first_type_t<std::remove_reference_t<Cursors>...>::value_type, typename T = typename FirstCursor::value_type>
std::optional< lager::reader< T > > kislager::fold_optional_cursors ( const Func & func,
Cursors &&... cursors )

Fold all valid optional cursors from a set into one by using func

Example:

std::optional<lager::reader<int>> brushSize1 = ...; std::optional<lager::reader<int>> brushSize2 = ...;

std::optional<lager::reader<int>> maxSize = fold_optional_cursors(&std::max, brushSize1, brushSize2);

The resulting reader 'maxSize' will hold the maximum value of the two brushes, or nothing if the source readers do not exist.

Definition at line 37 of file KisLager.h.

37 {
38 auto fold_func = [func] (const auto &lhs, const auto &rhs) {
39 return lager::with(lhs, rhs).map(func);
40 };
41
42 return kismpl::fold_optional(fold_func, cursors...);
43}
std::optional< T > fold_optional(Fun &&fun, Args &&...args)
Definition KisMpl.h:137

References kismpl::fold_optional().