mrdocs::YCombinator

Enables recursive lambdas by passing a self‐reference as the first argument.

Synopsis

Declared in <mrdocs/ADT/Overload.hpp>

template<class F>
class YCombinator;

Member Functions

Name

Description

YCombinator [constructor]

Constructs a YCombinator from the given callable.

operator()

Function call operators

Non-Member Functions

Name

Description

yCombinator

Factory that creates a YCombinator from a callable.

Description

YCombinator stores a callable F and exposes operator() that forwards arguments to F, prepending a reference to *this so that F can recurse.

Overloads are provided for &, const&, &&, const&& to preserve value category.

auto fact = fn::yCombinator( []self, int n) ‐> long long { return n <= 1 ? 1 : n * self(n ‐ 1); }); auto r = fact(10);

Template Parameters

Name

Description

F

The callable to wrap.

Created with MrDocs