Here is a C++ snippet that I found in the documentation of the cpp.react library:
auto in = D::MakeVar(0);
auto op1 = in ->* [] (int in)
{
int result = in
@Praetorian's answer is correct. This is code from cpp.react
///////////////////////////////////////////////////////////////////////////////////////////////////
/// operator->* overload to connect inputs to a function and return the resulting node.
///////////////////////////////////////////////////////////////////////////////////////////////////
// Single input
template
<
typename D,
typename F,
template class TSignal,
typename TValue,
class = std::enable_if<
IsSignal>::value>::type
>
auto operator->*(const TSignal& inputNode, F&& func)
-> Signal::type>
{
return D::MakeSignal(std::forward(func), inputNode);
}
// Multiple inputs
template
<
typename D,
typename F,
typename ... TSignals
>
auto operator->*(const InputPack& inputPack, F&& func)
-> Signal::type>
{
return apply(
REACT_IMPL::ApplyHelper::MakeSignal,
std::tuple_cat(std::forward_as_tuple(std::forward(func)), inputPack.Data));
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/// Comma operator overload to create input pack from 2 signals.
///////////////////////////////////////////////////////////////////////////////////////////////////
template
<
typename D,
typename TLeftVal,
typename TRightVal
>
auto operator,(const Signal& a, const Signal& b)
-> InputPack
{
return InputPack(a, b);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/// Comma operator overload to append node to existing input pack.
///////////////////////////////////////////////////////////////////////////////////////////////////
template
<
typename D,
typename ... TCurValues,
typename TAppendValue
>
auto operator,(const InputPack& cur, const Signal& append)
-> InputPack
{
return InputPack(cur, append);
}
as you can see it overloaded free function operator->*
which takes a signal (D::MakeVar(0)
) and a functor (lambda)
and free function operator,
which takes two signal