LILAC
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | List of all members
apply< T, dim > Struct Template Reference

Class containing functions for mapping over generic objects. More...

#include <type_operators.hpp>

Public Member Functions

 static_assert (dim >=1,"A dimension less then one has been given to the apply structure")

Static Public Member Functions

template<class Lambda >
static void transform (T &inval, Lambda &&func)
template<template< size_t > class Lambda>
static void transform (T &inval)
 Version of transform where Lambda takes dim as a template parameter.
template<class Lambda , class Final >
static void transform (T &inval, Lambda &&func, Final &&finish)
template<class Lambda , class Trans >
static void map_into (const T &inval, Lambda &&func, Trans &outval)
template<class Lambda , class Trans >
static Trans map (const T &inval, Lambda &&func)
 Generates a variable of type trans with the functor by mapping each coordinate of the first to the second.
template<class Lambda , class Trans , class constr , class postop >
static Trans map (const T &inval, Lambda &&func, postop &&finish, constr &&build)
 Mapper with custom building and postoperation functors.

Private Member Functions

static auto dim pull (inval))

Static Private Member Functions

template<class U >
static auto get (U &inval)-> decltype(get<U
 helper function to reduce complexity of get function calls

Detailed Description

template<class T, size_t dim = float_traits<T>::dim>
struct apply< T, dim >

Class containing functions for mapping over generic objects.

Definition at line 127 of file type_operators.hpp.

Member Function Documentation

template<class T , size_t dim = float_traits<T>::dim>
template<class U >
static auto apply< T, dim >::get ( U &  inval)
staticprivate

helper function to reduce complexity of get function calls

template<class T , size_t dim = float_traits<T>::dim>
template<class Lambda , class Trans >
static Trans apply< T, dim >::map ( const T &  inval,
Lambda &&  func 
)
inlinestatic

Generates a variable of type trans with the functor by mapping each coordinate of the first to the second.

Definition at line 224 of file type_operators.hpp.

Here is the call graph for this function:

template<class T , size_t dim = float_traits<T>::dim>
template<class Lambda , class Trans , class constr , class postop >
static Trans apply< T, dim >::map ( const T &  inval,
Lambda &&  func,
postop &&  finish,
constr &&  build 
)
inlinestatic

Mapper with custom building and postoperation functors.

Definition at line 231 of file type_operators.hpp.

Here is the call graph for this function:

template<class T , size_t dim = float_traits<T>::dim>
template<class Lambda , class Trans >
static void apply< T, dim >::map_into ( const T &  inval,
Lambda &&  func,
Trans &  outval 
)
inlinestatic

Definition at line 216 of file type_operators.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T , size_t dim = float_traits<T>::dim>
static auto dim apply< T, dim >::pull ( inval  )
inlineprivate

Definition at line 131 of file type_operators.hpp.

Here is the caller graph for this function:

template<class T , size_t dim = float_traits<T>::dim>
apply< T, dim >::static_assert ( dim >=  1,
"A dimension less then one has been given to the apply< T, dim > structure"   
)

Here is the caller graph for this function:

template<class T , size_t dim = float_traits<T>::dim>
template<class Lambda >
static void apply< T, dim >::transform ( T &  inval,
Lambda &&  func 
)
inlinestatic

This function transforms a value, based upon the function func. For each dimension, func is called with the current dimension of inval and the dimension number, and returns the new value for the current dimension of inval.

For example, if the data type was an array, the transform function would be equivilant to

inval[0] = func(inval[0], 1);
inval[1] = func(inval[1], 2);
...
inval[i] = func(inval[i], i+1);

Note that in the above example, the loop is unrolled, and the dimensions are 1-indexed instead of zero indexed. In addition, the compiler should inline the call to func is possible.

In addition, note that the function isn't given knowledge of inval as a whole, simply each respective dimension. This is because inval is modified during the process, so passing inval to the function wouldn't be meaningful.

You can get around this by binding a copy of inval to the passed function for use in calculations, like

apply<T, dim>::transform(some_val, [some_val](T& inval, size_t dim){
auto calc_val = do_calculation(some_val);
inval.dimensions[dim-1] = calc_val * inval.dimensions[dim-1];
}

If the binding was be reference [&some_val], this would be incorrect as the value being used in the lambda would be the same as the value being modified by transform

Parameters
invalThe value being transformed
funcThe function object that operates on each dimension. Can be any callable object

Definition at line 170 of file type_operators.hpp.

Here is the caller graph for this function:

template<class T , size_t dim = float_traits<T>::dim>
template<template< size_t > class Lambda>
static void apply< T, dim >::transform ( T &  inval)
inlinestatic

Version of transform where Lambda takes dim as a template parameter.

This version of transform takes a struct as a template parameter, where the struct takes the dimension as a template parameter and has a function called apply which takes the proper type as a reference parameter and does the coordinate transformation

For example, one may have

template<size_t dim>
struct do_calc{
static void apply(double& inval){
inval = calculation_based_on_dim(inval);
}
};
...
...
...
double x;
...
...

Definition at line 199 of file type_operators.hpp.

template<class T , size_t dim = float_traits<T>::dim>
template<class Lambda , class Final >
static void apply< T, dim >::transform ( T &  inval,
Lambda &&  func,
Final &&  finish 
)
inlinestatic

This function transforms an existing values, based upon the functions func and finish that have been passed First, transform is called with inval and func, and then finish is applied

Parameters
finishthe function applied after the calculations are finished

Definition at line 210 of file type_operators.hpp.

Here is the call graph for this function:


The documentation for this struct was generated from the following file: