Lambda

◆ _1

using metal::_1 = typedef metal::arg<1U>

#include <metal/lambda/arg.hpp>

Description

Predefined placeholder.

◆ _2

using metal::_2 = typedef metal::arg<2U>

#include <metal/lambda/arg.hpp>

Description

Predefined placeholder.

◆ _3

using metal::_3 = typedef metal::arg<3U>

#include <metal/lambda/arg.hpp>

Description

Predefined placeholder.

◆ _4

using metal::_4 = typedef metal::arg<4U>

#include <metal/lambda/arg.hpp>

Description

Predefined placeholder.

◆ _5

using metal::_5 = typedef metal::arg<5U>

#include <metal/lambda/arg.hpp>

Description

Predefined placeholder.

◆ _6

using metal::_6 = typedef metal::arg<6U>

#include <metal/lambda/arg.hpp>

Description

Predefined placeholder.

◆ _7

using metal::_7 = typedef metal::arg<7U>

#include <metal/lambda/arg.hpp>

Description

Predefined placeholder.

◆ _8

using metal::_8 = typedef metal::arg<8U>

#include <metal/lambda/arg.hpp>

Description

Predefined placeholder.

◆ _9

using metal::_9 = typedef metal::arg<9U>

#include <metal/lambda/arg.hpp>

Description

Predefined placeholder.

◆ always

template<class val >
using metal::always = typedef typename detail::_always<val>::type

#include <metal/lambda/always.hpp>

Description

Lifts a Value to an n-ary Lambda that always evaluates to that Value, regardless of the argument(s) it's invoked with.

Usage

For any and Value val

using result = metal::always<val>;
Returns
: Lambda
Semantics:
Equivalent to
using result = metal::lambda<expr>;
where expr is an Expression such that
template<class...>
using expr = val;

Example

using void_ = metal::always<void>;
IS_SAME(metal::invoke<void_>, void);
IS_SAME(metal::invoke<metal::always<void_>, bool, char, long, float>, void_);

See Also

See also
lambda, invoke, partial, bind

◆ apply

template<class lbd , class seq >
using metal::apply = typedef typename detail::_apply<lbd, seq>::type

#include <metal/lambda/apply.hpp>

Description

Invokes a Lambda with the Values contained in a List.

Usage

For any Lambda lbd and List l

using result = metal::apply<lbd, l>;
Returns
: Value
Semantics:
If l contains elements l[0], ..., l[m-1], then
using result = metal::invoke<lbd, l[0], ..., l[m-1]>;

Example

See Also

See also
lambda, invoke, list

◆ arg

template<std::size_t n>
using metal::arg = typedef typename detail::_arg<n>::type

#include <metal/lambda/arg.hpp>

Description

A parametric Lambda that selects the n-th argument it is invoked with.

Usage

For any nonzero positive integral value n

using result = metal::arg<n>;
Returns
: Lambda
Semantics:
Equivalent to
using result = metal::lambda<expr>;
where expr is an Expression such that expr<val_0, ..., val_n-1, ..., val_m-1> yields val_n-1.

Example

IS_SAME(metal::invoke<metal::arg<1>, bool, char, long, float>, bool);
IS_SAME(metal::invoke<metal::arg<2>, bool, char, long, float>, char);
IS_SAME(metal::invoke<metal::arg<3>, bool, char, long, float>, long);
IS_SAME(metal::invoke<metal::arg<4>, bool, char, long, float>, float);

See Also

See also
lambda, invoke, bind, always

◆ as_lambda

template<class val >
using metal::as_lambda = typedef typename detail::_as_lambda<val>::type

#include <metal/lambda/lambda.hpp>

Description

Given any Value that is a specialization of a template class or union whose template parameters are all themselves Values, constructs a Lambda that contains that template.

Usage

For any Value val

using result = metal::as_lambda<val>;
Returns
: Lambda

Example

IS_SAME(metal::as_lambda<std::shared_ptr<int>>, metal::lambda<std::shared_ptr>);
IS_SAME(metal::as_lambda<std::unique_ptr<int>>, metal::lambda<std::unique_ptr>);
IS_SAME(metal::as_lambda<std::tuple<int, char, float>>, metal::lambda<std::tuple>);

See Also

See also
lambda, as_list

◆ bind

template<class lbd , class... vals>
using metal::bind = typedef typename detail::_bind<lbd, vals...>::type

#include <metal/lambda/bind.hpp>

Description

Provides higher-order composition of Lambdas.

Tip
Use metal::arg<n> as a placeholder for the n-th argument.

Usage

For any Lambdas lbd and lbd_0, ..., lbd_n-1

using result = metal::bind<lbd, lbd_0, ..., lbd_n-1>;
Returns
: Lambda
Semantics:
If lbd holds Expression f and, likewise, lbd_0, ..., lbd_n-1 hold Expressions f_0, ..., f_n-1, then
using result = metal::lambda<g>;
where g is an Expression such that
template<class... args>
using g = f<f_0<args...>, ...<args...>, f_n-1<args...>>;

Example

See Also

See also
lambda, invoke, arg, always

◆ invoke

template<class lbd , class... vals>
using metal::invoke = typedef metal::apply<lbd, metal::list<vals...> >

#include <metal/lambda/invoke.hpp>

Description

Invokes a Lambda with the given Values as arguments.

Usage

For any Lambda lbd and Values val_0, ..., val_n-1

using result = metal::invoke<lbd, val_0, ..., val_n-1>;
Returns
: Value
Semantics:
If lbd holds Expression expr, then
using result = expr<val_0, ..., val_n-1>;

Example

See Also

See also
lambda, is_invocable

◆ is_invocable

template<class lbd , class... vals>
using metal::is_invocable = typedef same<std::false_type, typename std::is_base_of<value<>, detail::caller<invoke, lbd, vals...> >::type>

#include <metal/lambda/is_invocable.hpp>

Description

Checks whether a Lambda is invocable with some Values.

Usage

For any Lambda lbd and Values val_0, ..., val_n-1

using result = metal::is_invocable<lbd, val_0, ..., val_n-1>;
Returns
: Number
Semantics:
If lbd holds Expression expr, and expr<val_0, ..., val_n-1> is well defined after template substitution, then
using result = metal::true_;
otherwise
using result = metal::false_;

Example

template<class val>
using array = metal::identity<val[]>; // MSVC friendly
IS_SAME(metal::is_invocable<lbd, void>, metal::false_); // void[] is ill-formed

See Also

See also
lambda, invoke

◆ is_lambda

template<class val >
using metal::is_lambda = typedef typename detail::_is_lambda<val>::type

#include <metal/lambda/lambda.hpp>

Description

Checks whether some Value is a Lambda.

Usage

For any Value val

using result = metal::is_lambda<val>;
Returns
: Number
Semantics:
If val is a Lambda, then
using result = metal::true_;
otherwise
using result = metal::false_;

Example

See Also

See also
lambda, is_value, is_number, is_pair, is_list, is_map

◆ lambda

template<template< class... > class expr>
using metal::lambda = typedef { }

#include <metal/lambda/lambda.hpp>

Description

Constructs a Lambda out of an Expression.

Usage

For any Expression expr

using result = metal::lambda<expr>;
Returns
: Lambda

See Also

See also
is_lambda

◆ lazy

template<template< class... > class expr>
using metal::lazy = typedef metal::bind<metal::lambda<metal::eval>, metal::lambda<expr> >

#include <metal/lambda/lazy.hpp>

Description

Constructs a Lambda out of a lazy expression, that is, an Expression whose return Value is defined as a nested typename type.

Usage

For any Expression expr

using result = metal::lazy<expr>;
Returns
: Lambda
Semantics:
Equivalent to
using result = metal::lambda<eager>;
where eager is an Expression such that
template<class... args>
using eager = typename expr<args...>::type;

Example

IS_SAME(metal::invoke<metal::lazy<std::decay>, int()>, int(*)());
IS_SAME(metal::invoke<metal::lazy<std::common_type>, int[], void*>, void*);

See Also

See also
lambda, eval

◆ partial

template<class lbd , class... vals>
using metal::partial = typedef typename detail::_partial<lbd, vals...>::type

#include <metal/lambda/partial.hpp>

Description

Partially invokes a Lambda with some Values.

Usage

For any Lambda lbd and Values val_0, ..., val_n-1

using result = metal::partial<lbd, val_0, ..., val_n-1>;
Returns
: Lambda
Semantics:
If lbd holds Expression f, then
using result = metal::lambda<g>;
where g is an Expression such that
template<class... args>
using g = f<val_0, ..., val_n-1, args...>;

Example

See Also

See also
lambda, invoke, bind, always

◆ trait

template<template< class... > class expr>
using metal::trait = typedef metal::bind<metal::lambda<metal::as_number>, metal::lambda<expr> >

#include <metal/lambda/trait.hpp>

Description

Constructs a predicate out of a trait, that is a Lambda that evaluates to a Number, out of an Expression that defines a nested integral constant value convertible to metal::int_.

Usage

For any Expression expr

using result = metal::trait<expr>;
Returns
: Lambda
Semantics:
Equivalent to
using result = metal::lambda<pred>;
where pred is an Expression such that
template<class... args>
using pred = metal::number<expr<args...>::value>;

Example

See Also

See also
lambda, number