Observable Reference
Generic observable objects for C++
Macros | Functions
Expressions

Everything related to observable expressions. More...

Macros

#define OBSERVABLE_ADAPT_FILTER(NAME, OP)
 Create an expression filter from a callable. More...
 

Functions

template<typename ValueType , typename ... Args>
auto observable::expr::construct (Args &&... args) -> std::enable_if_t< expr_detail::are_any_observable< Args ... >::value, expression_node< ValueType >>
 Construct an object. More...
 
template<typename To , typename From >
auto observable::expr::static_expr_cast (From &&from) -> std::enable_if_t< expr_detail::is_observable< From >::value, expression_node< To >>
 Cast an expression node to another type using static_cast. More...
 
template<typename To , typename From >
auto observable::expr::reinterpret_expr_cast (From &&from) -> std::enable_if_t< expr_detail::is_observable< From >::value, expression_node< To >>
 Cast an expression node to another type using reinterpret_cast. More...
 
template<typename Cond , typename TrueVal , typename FalseVal >
auto observable::expr::select (Cond &&cond, TrueVal &&true_val, FalseVal &&false_val)
 Select between two values based on a condition. More...
 
template<typename ... Values>
auto observable::expr::min (Values ... values)
 Return the argument with the minimum value. More...
 
template<typename ... Values>
auto observable::expr::max (Values ... values)
 Return the argument with the maximum value. More...
 
template<typename ... Values>
auto observable::expr::mean (Values ... values)
 Return the mean of the arguments. More...
 
template<typename Val , typename Low , typename High >
auto observable::expr::clamp (Val &&val, Low &&low, High &&high)
 Keep a value between a minimum and maximum. More...
 
template<typename ... Args>
auto observable::expr::zip (Args &&... args)
 Convert a number of arguments to a tuple containing the arguments. More...
 
template<typename T >
auto observable::expr::abs (T &&val)
 Compute the absolute value of an integral expression. More...
 
template<typename X , typename Y >
auto observable::expr::div (X &&x, Y &&y)
 Compute both the quotient and the remainder of the division of the numerator x by the denominator y. More...
 
template<typename T >
auto observable::expr::exp (T &&v)
 Computes e (Euler's number) raised to the given power. More...
 
template<typename T >
auto observable::expr::exp2 (T &&v)
 Computes 2 raised to the given power. More...
 
template<typename T >
auto observable::expr::log (T &&v)
 Computes the the natural (base e) logarithm of the provided argument. More...
 
template<typename T >
auto observable::expr::log10 (T &&v)
 Computes the common (base-10) logarithm of the provided argument. More...
 
template<typename T >
auto observable::expr::log2 (T &&v)
 Computes the binary (base-2) logarithm of the provided argument. More...
 
template<typename B , typename E >
auto observable::expr::pow (B &&b, E &&e)
 Computes the value of the provided base raised to the power of the provided exponent. More...
 
template<typename T >
auto observable::expr::sqrt (T &&v)
 Computes the square root of the provided argument. More...
 
template<typename T >
auto observable::expr::cbrt (T &&v)
 Computes the cubic root of the provided argument. More...
 
template<typename X , typename Y >
auto observable::expr::hypot (X &&x, Y &&y)
 Computes the square root of the sum of the squares of x and y, without undue overflow or underflow at intermediate stages of the computation. More...
 
template<typename T >
auto observable::expr::sin (T &&v)
 Computes the sine of the provided argument (measured in radians). More...
 
template<typename T >
auto observable::expr::cos (T &&v)
 Computes the cosine of the provided argument (measured in radians). More...
 
template<typename T >
auto observable::expr::tan (T &&v)
 Computes the tangent of the provided argument (measured in radians). More...
 
template<typename T >
auto observable::expr::asin (T &&v)
 Computes the arc sine of the provided argument. More...
 
template<typename T >
auto observable::expr::acos (T &&v)
 Computes the arc cosine of the provided argument. More...
 
template<typename T >
auto observable::expr::atan (T &&v)
 Computes the arc tangent of the provided argument. More...
 
template<typename Y , typename X >
auto observable::expr::atan2 (Y &&y, X &&x)
 Computes the arc tangent of y / x using the signs of arguments to determine the correct quadrant. More...
 
template<typename T >
auto observable::expr::ceil (T &&v)
 Nearest integer not less than the given value. More...
 
template<typename T >
auto observable::expr::floor (T &&v)
 Nearest integer not greater than the given value. More...
 
template<typename T >
auto observable::expr::trunc (T &&v)
 Nearest integer not greater in magnitude than the given value. More...
 
template<typename T >
auto observable::expr::round (T &&v)
 Nearest integer, rounding away from zero in halfway cases. More...
 

Detailed Description

Everything related to observable expressions.

Macro Definition Documentation

◆ OBSERVABLE_ADAPT_FILTER

#define OBSERVABLE_ADAPT_FILTER (   NAME,
  OP 
)
Value:
template <typename ... Args> \
inline auto NAME(Args && ... args) \
-> std::enable_if_t< \
{ \
return ::observable::expr::expr_detail::make_node(OP, std::forward<Args>(args) ...); \
}
Check if any of the provided types are observable.
Definition: utility.hpp:33
auto make_node(T &&val)
Create a node from a regular type.
Definition: utility.hpp:104
typename result_node< Op, Args ... >::type result_node_t
Type of the expression_node created for an expression with callable Op and corresponding arguments...
Definition: utility.hpp:98

Create an expression filter from a callable.

Expression filters take expression nodes as arguments and return an expression node.

This macro wraps a regular callable (i.e. one that does not work with expression nodes) and turns it into an expression filter.

Parameters
NAMEThe name that will be used for the expression filter. This must be a valid function identifier.
OPCallable instance that will be converted to an expression filter. This instance must be copy-constructible.

Function Documentation

◆ construct()

template<typename ValueType , typename ... Args>
auto observable::expr::construct ( Args &&...  args) -> std::enable_if_t<expr_detail::are_any_observable<Args ...>::value, expression_node<ValueType>>
inline

Construct an object.

Parameters
argsArguments to be passed to the object's constructor. You must have at least one observable argument.
Returns
Expression node having the newly constructed object as its result.
Template Parameters
ValueTypeThe constructed object's type.
ArgsArgument pack for the parameters passed to the constructor.

◆ static_expr_cast()

template<typename To , typename From >
auto observable::expr::static_expr_cast ( From &&  from) -> std::enable_if_t< expr_detail::is_observable<From>::value, expression_node<To>>
inline

Cast an expression node to another type using static_cast.

Parameters
fromIncoming type.
Returns
Expression node having the To type.

◆ reinterpret_expr_cast()

template<typename To , typename From >
auto observable::expr::reinterpret_expr_cast ( From &&  from) -> std::enable_if_t< expr_detail::is_observable<From>::value, expression_node<To>>
inline

Cast an expression node to another type using reinterpret_cast.

Parameters
fromIncoming type.
Returns
Expression node having the To type.

◆ select()

template<typename Cond , typename TrueVal , typename FalseVal >
auto observable::expr::select ( Cond &&  cond,
TrueVal &&  true_val,
FalseVal &&  false_val 
)

Select between two values based on a condition.

This is basically the ternary operator for expressions.

Parameters
condA value that evaluates to true or false. This will be used to choose the return value.
true_valValue that will be returned if cond evaluates to true.
false_valValue that will be returned if cond evaluates to false.
Returns
One of true_val or false_val.

◆ min()

template<typename ... Values>
auto observable::expr::min ( Values ...  values)

Return the argument with the minimum value.

Will use the less-than operator to compare values.

Parameters
values... Arguments from which the minimum will be chosen.
Returns
The minimum argument.

◆ max()

template<typename ... Values>
auto observable::expr::max ( Values ...  values)

Return the argument with the maximum value.

Will use the less-than operator to compare values.

Parameters
values... Arguments from which the maximum will be chosen.
Returns
The maximum argument.

◆ mean()

template<typename ... Values>
auto observable::expr::mean ( Values ...  values)

Return the mean of the arguments.

Parameters
values... Arguments for which the mean will be computed.
Returns
The mean value of the arguments.

◆ clamp()

template<typename Val , typename Low , typename High >
auto observable::expr::clamp ( Val &&  val,
Low &&  low,
High &&  high 
)

Keep a value between a minimum and maximum.

Will use the less-than operator to compare values.

Parameters
valValue to clamp.
lowThe minimum allowed value of the val parameter.
highThe maximum allowed value of the val parameter.
Returns
The clamped value.

◆ zip()

template<typename ... Args>
auto observable::expr::zip ( Args &&...  args)

Convert a number of arguments to a tuple containing the arguments.

Parameters
args... Arguments to pack into a tuple.
Returns
Tuple containing the provided arguments.

◆ abs()

template<typename T >
auto observable::expr::abs ( T &&  val)

Compute the absolute value of an integral expression.

See also
std::abs

◆ div()

template<typename X , typename Y >
auto observable::expr::div ( X &&  x,
Y &&  y 
)

Compute both the quotient and the remainder of the division of the numerator x by the denominator y.

See also
std::div

◆ exp()

template<typename T >
auto observable::expr::exp ( T &&  v)

Computes e (Euler's number) raised to the given power.

See also
std::exp

◆ exp2()

template<typename T >
auto observable::expr::exp2 ( T &&  v)

Computes 2 raised to the given power.

See also
std::exp2

◆ log()

template<typename T >
auto observable::expr::log ( T &&  v)

Computes the the natural (base e) logarithm of the provided argument.

See also
std::log

◆ log10()

template<typename T >
auto observable::expr::log10 ( T &&  v)

Computes the common (base-10) logarithm of the provided argument.

See also
std::log10

◆ log2()

template<typename T >
auto observable::expr::log2 ( T &&  v)

Computes the binary (base-2) logarithm of the provided argument.

See also
std::log2

◆ pow()

template<typename B , typename E >
auto observable::expr::pow ( B &&  b,
E &&  e 
)

Computes the value of the provided base raised to the power of the provided exponent.

See also
std::pow

◆ sqrt()

template<typename T >
auto observable::expr::sqrt ( T &&  v)

Computes the square root of the provided argument.

See also
std::sqrt

◆ cbrt()

template<typename T >
auto observable::expr::cbrt ( T &&  v)

Computes the cubic root of the provided argument.

See also
std::cbrt

◆ hypot()

template<typename X , typename Y >
auto observable::expr::hypot ( X &&  x,
Y &&  y 
)

Computes the square root of the sum of the squares of x and y, without undue overflow or underflow at intermediate stages of the computation.

See also
std::hypot

◆ sin()

template<typename T >
auto observable::expr::sin ( T &&  v)

Computes the sine of the provided argument (measured in radians).

See also
std::sin

◆ cos()

template<typename T >
auto observable::expr::cos ( T &&  v)

Computes the cosine of the provided argument (measured in radians).

See also
std::cos

◆ tan()

template<typename T >
auto observable::expr::tan ( T &&  v)

Computes the tangent of the provided argument (measured in radians).

See also
std::tan

◆ asin()

template<typename T >
auto observable::expr::asin ( T &&  v)

Computes the arc sine of the provided argument.

See also
std::asin

◆ acos()

template<typename T >
auto observable::expr::acos ( T &&  v)

Computes the arc cosine of the provided argument.

See also
std::acos

◆ atan()

template<typename T >
auto observable::expr::atan ( T &&  v)

Computes the arc tangent of the provided argument.

See also
std::atan

◆ atan2()

template<typename Y , typename X >
auto observable::expr::atan2 ( Y &&  y,
X &&  x 
)

Computes the arc tangent of y / x using the signs of arguments to determine the correct quadrant.

See also
std::atan2

◆ ceil()

template<typename T >
auto observable::expr::ceil ( T &&  v)

Nearest integer not less than the given value.

See also
std::ceil

◆ floor()

template<typename T >
auto observable::expr::floor ( T &&  v)

Nearest integer not greater than the given value.

See also
std::floor

◆ trunc()

template<typename T >
auto observable::expr::trunc ( T &&  v)

Nearest integer not greater in magnitude than the given value.

See also
std::trunc

◆ round()

template<typename T >
auto observable::expr::round ( T &&  v)

Nearest integer, rounding away from zero in halfway cases.

See also
std::round