LILAC
|
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 |
Class containing functions for mapping over generic objects.
Definition at line 127 of file type_operators.hpp.
|
staticprivate |
helper function to reduce complexity of get function calls
|
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.
|
inlinestatic |
Mapper with custom building and postoperation functors.
Definition at line 231 of file type_operators.hpp.
|
inlinestatic |
Definition at line 216 of file type_operators.hpp.
|
inlineprivate |
apply< T, dim >::static_assert | ( | dim >= | 1, |
"A dimension less then one has been given to the apply< T, dim > structure" | |||
) |
|
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
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
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
inval | The value being transformed |
func | The function object that operates on each dimension. Can be any callable object |
Definition at line 170 of file type_operators.hpp.
|
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
Definition at line 199 of file type_operators.hpp.
|
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
finish | the function applied after the calculations are finished |
Definition at line 210 of file type_operators.hpp.