|
template<typename... NewChildren> |
constexpr auto | replaceChildren (NewChildren &&... newChildren) const |
|
constexpr auto | getBindResult () const |
| Get the result of binding this object's values to the variable user. More...
|
|
constexpr auto | filterValues () const |
| Return a VariableBinding with all values that aren't used by the variable user removed. More...
|
|
template<VariableName Name, typename U > |
constexpr auto | setValue (U &&value) const |
| Set or substitute a value in the VariableBinding with a different value. More...
|
|
template<VariableName Name> |
constexpr const auto & | getValue () const |
| Get the value with the given name. More...
|
|
template<VariableName Name> |
constexpr auto & | getValue () |
| Get the value with the given name. More...
|
|
constexpr decltype(auto) | operator() (Ts &&... values) const |
| Calls operator() on the result of binding this object to a set of variables. More...
|
|
constexpr auto & | get () |
| Get the Ith child. More...
|
|
constexpr const auto & | get () const |
| Get the Ith child. More...
|
|
constexpr auto | bind (Ts &&... values) const |
| Bind a specified set of values to the corresponding variables in this expression. More...
|
|
constexpr auto | bind (Ts &&... values) const |
| Bind a set of values to the expression's variables. More...
|
|
constexpr auto | substitute (const New &newValue) const |
| Substitute all instances of the given type with the the given new value. More...
|
|
constexpr auto | replaceChildren (NewChildren &&... newChildren) const |
| Replace the children of this variable user with the given new children. More...
|
|
template<typename Child, typename Names, typename... Ts>
class sp::VariableBinding< Child, Names, Ts >
Represents a variable user and values to bind to it.
Use getVariableBinding() to construct.
This is useful for reasoning about a variable user in context with what is intended to be bound to it. For examples:
- Algebraic transformations can be made, and then the variables that optimized away can be removed from the binding.
- Two variables to be bound can be compared for equality at run time, and a version with one of the variables substituted for the other can be created and then bound.
This class makes it possible for a variadic function (like the specialization engine) to accept arguments that may not all be intended to be bound to the variable user.
This class is also useful for passing around arguments, e.g to a CUDA kernel, so that the compiler can prove where two arguments in a resulting expression (e.g: a TensorExpr) are the same.
- Template Parameters
-
Names | The variable names of each value to bind. These names need to be specified explicitly so that the variable user and variables to bind can be operated on independently. It is not necessary to have an value (and name) to bind for each variable in the variable user. It is permitted to specify values (and names) to bind for variables that do not exist in the variable user. These will be ignored. There is a templade deduction guide so that if the names are not explicitly given, they are inferred to be the variable names of the child. |
Child | The variable user type. If bind() is called on a VariableBinding, it is applied to the child variable user, without paying any attention to whether or not there is also an value in the VariableBinding for the variables given to bind(). When this is done, any values in the VariableBinding corresponding to those bound with bind() become ignored as they are not variables in the result of the bind(). |
Ts | The types of the values to bind. |
template<typename Child , typename Names , typename... Ts>
Return a VariableBinding with all values that aren't used by the variable user removed.
This is useful if the variable binding is to be passed across an ABI boundary, e.g: during a CUDA kernel call, as it avoids the need to copy arguments that would not actually be used.
- Returns
- A copy of this object with the unused values removed.
template<typename Child , typename Names , typename... Ts>
Set or substitute a value in the VariableBinding with a different value.
If the variable name is in the VariableBinding already, it will be replaced in the result. If it is not, it will be added in the result. It is permitted to change the type of a value with this operation.
- Parameters
-
value | The value to set or substitute. |
- Template Parameters
-
Name | The name corresponding to the value to be added or substituted. |
- Returns
- A copy of this object with the changed values.