Expression Templates Library (ETL)
Public Types | Public Member Functions | Friends | List of all members
etl::generator_expr< Generator > Class Template Referencefinal

A generator expression. More...

#include <generator_expr.hpp>

Public Types

using value_type = typename Generator::value_type
 The type of value generated.
 

Public Member Functions

template<typename... Args>
 generator_expr (Args &&... args)
 Construct a generator expression and forward the arguments to the generator. More...
 
 generator_expr (const generator_expr &e)=default
 
 generator_expr (generator_expr &&e) noexcept=default
 
 generator_expr (generator_expr &e)
 Copy constructor for non-const argument. This simply forwards to the regular copy constructor to avoid the forwarding constructor to be used.
 
generator_exproperator= (const generator_expr &e)=delete
 
generator_exproperator= (generator_expr &&e)=delete
 
value_type operator[] ([[maybe_unused]] size_t i) const
 Returns the element at the given index. More...
 
value_type read_flat ([[maybe_unused]] size_t i) const
 Returns the value at the given index This function never alters the state of the container. More...
 
template<typename Y >
decltype(auto) gpu_compute_hint (Y &y) const
 Return a GPU computed version of this expression. More...
 
template<typename Y >
decltype(auto) gpu_compute (Y &y) const
 Return a GPU computed version of this expression. More...
 
template<typename E >
constexpr bool alias (const E &rhs) const noexcept
 Test if this expression aliases with the given expression. More...
 
value_type operator() () const
 Apply the functor. More...
 
const Generator & get_generator () const
 Returns a reference to the generator op. More...
 
template<typename L >
void assign_to (L &&lhs) const
 Assign to the given left-hand-side expression. More...
 
template<typename L >
void assign_add_to (L &&lhs) const
 Add to the given left-hand-side expression. More...
 
template<typename L >
void assign_sub_to (L &&lhs) const
 Sub from the given left-hand-side expression. More...
 
template<typename L >
void assign_mul_to (L &&lhs) const
 Multiply the given left-hand-side expression. More...
 
template<typename L >
void assign_div_to (L &&lhs) const
 Divide the given left-hand-side expression. More...
 
template<typename L >
void assign_mod_to (L &&lhs) const
 Modulo the given left-hand-side expression. More...
 
template<typename V >
void visit ([[maybe_unused]] V &&visitor) const
 Apply the given visitor to this expression and its descendants. More...
 
void ensure_cpu_up_to_date () const
 Ensures that the GPU memory is allocated and that the GPU memory is up to date (to undefined value).
 
void ensure_gpu_up_to_date () const
 Copy back from the GPU to the expression memory if necessary.
 

Friends

std::ostream & operator<< (std::ostream &os, const generator_expr &expr)
 Outputs the expression to the given stream. More...
 

Detailed Description

template<typename Generator>
class etl::generator_expr< Generator >

A generator expression.

Template Parameters
GeneratorThe generator functor

Constructor & Destructor Documentation

◆ generator_expr()

template<typename Generator >
template<typename... Args>
etl::generator_expr< Generator >::generator_expr ( Args &&...  args)
inlineexplicit

Construct a generator expression and forward the arguments to the generator.

Parameters
argsThe input arguments of the generator

Member Function Documentation

◆ alias()

template<typename Generator >
template<typename E >
constexpr bool etl::generator_expr< Generator >::alias ( const E &  rhs) const
inlinenoexcept

Test if this expression aliases with the given expression.

Parameters
rhsThe other expression to test
Returns
true if the two expressions aliases, false otherwise

◆ assign_add_to()

template<typename Generator >
template<typename L >
void etl::generator_expr< Generator >::assign_add_to ( L &&  lhs) const
inline

Add to the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ assign_div_to()

template<typename Generator >
template<typename L >
void etl::generator_expr< Generator >::assign_div_to ( L &&  lhs) const
inline

Divide the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ assign_mod_to()

template<typename Generator >
template<typename L >
void etl::generator_expr< Generator >::assign_mod_to ( L &&  lhs) const
inline

Modulo the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ assign_mul_to()

template<typename Generator >
template<typename L >
void etl::generator_expr< Generator >::assign_mul_to ( L &&  lhs) const
inline

Multiply the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ assign_sub_to()

template<typename Generator >
template<typename L >
void etl::generator_expr< Generator >::assign_sub_to ( L &&  lhs) const
inline

Sub from the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ assign_to()

template<typename Generator >
template<typename L >
void etl::generator_expr< Generator >::assign_to ( L &&  lhs) const
inline

Assign to the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ get_generator()

template<typename Generator >
const Generator& etl::generator_expr< Generator >::get_generator ( ) const
inline

Returns a reference to the generator op.

Returns
a reference to the generator op.

◆ gpu_compute()

template<typename Generator >
template<typename Y >
decltype(auto) etl::generator_expr< Generator >::gpu_compute ( Y &  y) const
inline

Return a GPU computed version of this expression.

Returns
a GPU-computed ETL expression for this expression

◆ gpu_compute_hint()

template<typename Generator >
template<typename Y >
decltype(auto) etl::generator_expr< Generator >::gpu_compute_hint ( Y &  y) const
inline

Return a GPU computed version of this expression.

Returns
a GPU-computed ETL expression for this expression

◆ operator()()

template<typename Generator >
value_type etl::generator_expr< Generator >::operator() ( ) const
inline

Apply the functor.

Returns
The new value of the generator

◆ operator[]()

template<typename Generator >
value_type etl::generator_expr< Generator >::operator[] ( [[maybe_unused] ] size_t  i) const
inline

Returns the element at the given index.

Parameters
iThe index
Returns
a reference to the element at the given index.

◆ read_flat()

template<typename Generator >
value_type etl::generator_expr< Generator >::read_flat ( [[maybe_unused] ] size_t  i) const
inline

Returns the value at the given index This function never alters the state of the container.

Parameters
iThe index
Returns
the value at the given index.

◆ visit()

template<typename Generator >
template<typename V >
void etl::generator_expr< Generator >::visit ( [[maybe_unused] ] V &&  visitor) const
inline

Apply the given visitor to this expression and its descendants.

Parameters
visitorThe visitor to apply

Friends And Related Function Documentation

◆ operator<<

template<typename Generator >
std::ostream& operator<< ( std::ostream &  os,
const generator_expr< Generator > &  expr 
)
friend

Outputs the expression to the given stream.

Parameters
osThe output stream
exprThe generator expr
Returns
The output stream

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