Number

◆ abs

template<typename num >
using metal::abs = typedef metal::max<num, metal::neg<num> >

#include <metal/number/abs.hpp>

Description

Computes absolute value of a Number .

Usage

For any Number num

using result = metal::abs<num>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<(num{} > 0) ? num{} : -num{}>;

Example

See Also

See also
number, inc, dec, neg, add, sub, mul, div, mod, pow

◆ add

template<typename... nums>
using metal::add = typedef fold_left<lambda<detail::add>, nums..., number<0> >

#include <metal/number/add.hpp>

Description

Computes the arithmetic addition of Numbers.

Usage

For any Numbers num_0, ..., num_n-1

using result = metal::add<num_0, ..., num_n-1>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<num_0{} + ... + num_n-1{}>;

Example

See Also

See also
number, abs, inc, dec, neg, sub, mul, div, mod, pow

◆ and_

template<typename... nums>
using metal::and_ = typedef metal::same<metal::false_, metal::not_<nums>...>

#include <metal/number/and.hpp>

Description

Computes the logical conjunction of Numbers.

Usage

For any Numbers num_0, ..., num_n-1

using result = metal::and_<num_0, ..., num_n-1>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<num_0{} && ... && num_n-1{}>;

Example

See Also

See also
number, not_, or_

◆ as_number

template<typename val >
using metal::as_number = typedef typename detail::_as_number<val>::type

#include <metal/number/number.hpp>

Description

Constructs a Number out of any Value that defines a nested integral constant value convertible to metal::int_.

Usage

For any Value val

using result = metal::as_number<val>;
Returns
: Number

Example

struct one { static const auto value = 1L; };
enum two { value = 2U };
IS_SAME(metal::as_number<std::integral_constant<short, 42>>, metal::number<42>);

See Also

See also
number

◆ dec

template<typename num >
using metal::dec = typedef metal::sub<num, metal::number<1> >

#include <metal/number/dec.hpp>

Description

Decrements a Number .

Usage

For any Number num

using result = metal::dec<num>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<num{} - 1>;

Example

See Also

See also
number, abs, inc, neg, add, sub, mul, div, mod, pow

◆ div

template<typename... nums>
using metal::div = typedef fold_left<lambda<detail::div>, nums..., number<1> >

#include <metal/number/div.hpp>

Description

Computes the quotient of the arithmetic division of Numbers.

Usage

For any Numbers num_0, ..., num_n-1

using result = metal::div<num_0, ..., num_n-1>;
Precondition
: All Numbers in num_1, ..., num_n-1 are nonzero
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<num_0{} / ... / num_n-1{}>;

Example

See Also

See also
number, abs, inc, dec, neg, add, sub, mul, mod, pow

◆ false_

using metal::false_ = typedef metal::number<false>

#include <metal/number/number.hpp>

Description

The boolean constant false.

See Also

See also
number

◆ greater

template<typename x , typename y >
using metal::greater = typedef metal::less<y, x>

#include <metal/number/greater.hpp>

Description

Checks whether a Number is greater than another.

Usage

For any Numbers x and y

using result = metal::greater<x, y>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<(x{} > y{})>;

Example

See Also

See also
number, less, max, min

◆ if_

template<typename cond , typename... then>
using metal::if_ = typedef detail::call<detail::_if_<cond>::template type, then...>

#include <metal/number/if.hpp>

Description

A conditional expression.

Usage

For any Number num and Values x, y

using result = metal::if<num, x, y>;
Returns
: Value
Semantics:
If num{} != false, then
using result = x;
otherwise
using result = y;
Tip
If num{} != false, y may be omitted.

Example

See Also

See also
number

◆ inc

template<typename num >
using metal::inc = typedef metal::add<num, metal::number<1> >

#include <metal/number/inc.hpp>

Description

Increments a Number .

Usage

For any Number num

using result = metal::inc<num>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<num::{} + 1>;

Example

See Also

See also
number, abs, dec, neg, add, sub, mul, div, mod, pow

◆ int_

using metal::int_ = typedef detail::int_

#include <metal/number/number.hpp>

Description

The underlying integral representation of Numbers.

See Also

See also
number

◆ is_number

template<typename val >
using metal::is_number = typedef typename detail::_is_number<val>::type

#include <metal/number/number.hpp>

Description

Checks whether some Value is a Number .

Usage

For any Value val

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

Example

struct one { static const auto value = 1L; };
enum two { value = 2U };
IS_SAME(metal::is_number<std::integral_constant<short, 42>>, metal::false_);

See Also

See also
number, is_value, is_lambda, is_pair, is_list, is_map

◆ less

template<typename x , typename y >
using metal::less = typedef typename detail::_less<x, y>::type

#include <metal/number/less.hpp>

Description

Checks whether a Number is less than another.

Usage

For any Numbers x and y

using result = metal::less<x, y>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<(x{} < y{})>;

Example

See Also

See also
number, greater, max, min

◆ max

template<typename... nums>
using metal::max = typedef fold_left<lambda<detail::max>, if_<is_number<nums>, nums>...>

#include <metal/number/max.hpp>

Description

Computes the maximum of Numbers.

Usage

For any Numbers num_0, ..., num_n-1

using result = metal::max<num_0, ..., num_n-1>;
Returns
: Number
Semantics:
If M the maximum between all Numbers in num_0, ..., num_n-1, then
using result = M;

Example

See Also

See also
number, greater, less, min

◆ min

template<typename... nums>
using metal::min = typedef fold_left<lambda<detail::min>, if_<is_number<nums>, nums>...>

#include <metal/number/min.hpp>

Description

Computes the minimum of Numbers.

Usage

For any Numbers num_0, ..., num_n-1

using result = metal::min<num_0, ..., num_n-1>;
Returns
: Number
Semantics:
If m the minimum between all Numbers in num_0, ..., num_n-1, then
using result = m;

Example

See Also

See also
number, greater, less, max

◆ mod

template<typename... nums>
using metal::mod = typedef fold_left<lambda<detail::mod>, if_<is_number<nums>, nums>...>

#include <metal/number/mod.hpp>

Description

Computes the remainder of the arithmetic division of Numbers.

Usage

For any Numbers num_0, ..., num_n-1

using result = metal::mod<num_0, ..., num_n-1>;
Precondition
: All Numbers in num_1, ..., num_n-1 are nonzero
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<num_0{} % ... % num_n-1{}>;

Example

See Also

See also
number, abs, inc, dec, neg, add, sub, mul, div, pow

◆ mul

template<typename... nums>
using metal::mul = typedef fold_left<lambda<detail::mul>, nums..., number<1> >

#include <metal/number/mul.hpp>

Description

Computes the arithmetic multiplication of Numbers.

Usage

For any Numbers num_0, ..., num_n-1

using result = metal::mul<num_0, ..., num_n-1>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<num_0{} * ... * num_n-1{}>;

Example

See Also

See also
number, abs, inc, dec, neg, add, sub, div, mod, pow

◆ neg

template<typename num >
using metal::neg = typedef metal::sub<metal::number<0>, num>

#include <metal/number/neg.hpp>

Description

Computes the additive inverse of a Number .

Usage

For any Number num

using result = metal::neg<num>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<-num{}>;

Example

See Also

See also
number, abs, inc, dec, add, sub, mul, div, mod, pow

◆ not_

template<typename num >
using metal::not_ = typedef metal::if_<num, metal::false_, metal::true_>

#include <metal/number/not.hpp>

Description

Computes the logical inverse of a Number .

Usage

For any Number num

using result = metal::not_<num>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<!num{}>;

Example

See Also

See also
number, and_, or_

◆ number

template<int_ v>
using metal::number = typedef std::integral_constant<metal::int_, v>

#include <metal/number/number.hpp>

Description

Constructs a Number out of an integral value.

Usage

For any integral constant N

using result = metal::number<N>;
Returns
: Number

See Also

See also
int_, true_, false_, is_number

◆ numbers

template<int_... vs>
using metal::numbers = typedef metal::list<metal::number<vs>...>

#include <metal/number/numbers.hpp>

Description

Constructs a List of Numbers out of a sequence of integral values.

Example

See Also

See also
int_, number, list

◆ or_

template<typename... nums>
using metal::or_ = typedef metal::not_<metal::same<metal::true_, metal::not_<nums>...> >

#include <metal/number/or.hpp>

Description

Computes the logical disjunction of Numbers.

Usage

For any Numbers num_0, ..., num_n-1

using result = metal::or_<num_0, ..., num_n-1>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<num_0{} || ... || num_n-1{}>;

Example

See Also

See also
number, not_, and_

◆ pow

template<typename... nums>
using metal::pow = typedef fold_left<lambda<detail::pow>, nums..., number<1> >

#include <metal/number/pow.hpp>

Description

Computes the arithmetic exponentiation of Numbers.

Usage

For any Numbers num_0, ..., num_n-1

using result = metal::pow<num_0, ..., num_n-1>;
Precondition
: metal::pow<num_0, ..., num_m-1> != metal::number<0> for all negative num_m
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<num_0{} ** ... ** num_n-1{}>;
Where x**y stands for x raised to the power of y
Warning
x**y is always null for y < 0 and |x| > 1 due to inherent limitations of integer arithmetic.

Example

See Also

See also
number, abs, inc, dec, neg, add, sub, mul, div, mod

◆ sub

template<typename... nums>
using metal::sub = typedef fold_left<lambda<detail::sub>, nums..., number<0> >

#include <metal/number/sub.hpp>

Description

Computes the arithmetic subtraction of Numbers.

Usage

For any Numbers num_0, ..., num_n-1

using result = metal::sub<num_0, ..., num_n-1>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<num_0{} - ... - num_n-1{}>;

Example

See Also

See also
number, abs, inc, dec, neg, add, mul, div, mod, pow

◆ true_

using metal::true_ = typedef metal::number<true>

#include <metal/number/number.hpp>

Description

The boolean constant true.

See Also

See also
number, int_