TRIQS/nda 2.0.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches

#include <nda/clef/placeholder.hpp>

Detailed Description

template<int N>
struct nda::clef::placeholder< N >

A placeholder is an empty struct, labelled by an int.

It is used in lazy expressions. For example:

#include <nda/nda.hpp>
#include <iostream>
int main() {
auto expr = i_ + j_;
std::cout << nda::clef::eval(expr, i_ = 1.0, j_ = 2.0) << std::endl;
}
__inline__ decltype(auto) eval(T const &obj, Pairs &&...pairs)
Generic function to evaluate expressions and other types.
Definition eval.hpp:188
Includes all relevant headers for the core nda library.
Single node of the expression tree.
A placeholder is an empty struct, labelled by an int.

Output:

3

Here expr is a lazy binary nda::clef::expr with the nda::clef::tags::plus tag, which can be evaluated later on with the nda::clef::eval function and by assigning values to the placeholders (see nda::clef::pair).

Template Parameters
NInteger label (must be < 64).

Definition at line 51 of file placeholder.hpp.

Public Member Functions

template<typename... Args>
auto operator() (Args &&...args) const
 Function call operator.
template<typename RHS>
pair< N, RHS > operator= (RHS &&rhs) const
 Assign a value to the placeholder.
template<typename T>
auto operator[] (T &&t) const
 Subscript operator.

Static Public Attributes

static constexpr int index = N
 Integer label.

Member Function Documentation

◆ operator()()

template<int N>
template<typename... Args>
auto nda::clef::placeholder< N >::operator() ( Args &&... args) const
inline

Function call operator.

Template Parameters
ArgsTypes of the function call arguments.
Parameters
argsFunction call arguments.
Returns
An nda::clef::expr object with the nda::clef::tags::function tag containing the placeholder (for the callable) and the given arguments.

Definition at line 78 of file placeholder.hpp.

◆ operator=()

template<int N>
template<typename RHS>
pair< N, RHS > nda::clef::placeholder< N >::operator= ( RHS && rhs) const
inline

Assign a value to the placeholder.

Template Parameters
RHSType of the right-hand side.
Parameters
rhsRight-hand side of the assignment.
Returns
An nda::clef::pair object, containing the integer label of the placeholder and the value assigned to it.

Definition at line 65 of file placeholder.hpp.

◆ operator[]()

template<int N>
template<typename T>
auto nda::clef::placeholder< N >::operator[] ( T && t) const
inline

Subscript operator.

Template Parameters
TType of the subscript argument.
Parameters
tSubscript argument.
Returns
An nda::clef::expr object with the nda::clef::tags::subscript tag containing the placeholder (for the object to be accessed) and the given argument.

Definition at line 91 of file placeholder.hpp.


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