Alexandria 2.31.4
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Pyston::Constant< T > Class Template Reference

#include <Constant.h>

Inheritance diagram for Pyston::Constant< T >:
Collaboration diagram for Pyston::Constant< T >:

Public Member Functions

 Constant (T value)
std::string repr () const final
eval (const Context &, const Arguments &) const final
void visit (Visitor &visitor) const final
Public Member Functions inherited from Pyston::Node< T >
 Node ()
virtual ~Node ()=default
template<typename... Args>
eval (const Context &context, Args... args) const
template<typename... Args>
eval (Args... args) const
Public Member Functions inherited from Pyston::NodeBase
 NodeBase (const std::type_index &type_index)
virtual ~NodeBase ()=default
const std::type_indextype () const

Private Attributes

m_value

Additional Inherited Members

Protected Member Functions inherited from Pyston::Node< T >
eval_helper (const Context &context, Arguments &arguments) const
template<typename A0, typename... AN>
eval_helper (const Context &context, Arguments &arguments, A0 v0, AN... an) const

Detailed Description

template<typename T>
class Pyston::Constant< T >

Node that just wraps a constant

Template Parameters
TThe type of the constant

Definition at line 32 of file Constant.h.

Constructor & Destructor Documentation

◆ Constant()

template<typename T>
Pyston::Constant< T >::Constant ( T value)
inlineexplicit

Constructor

Parameters
valueWrapped value

Definition at line 39 of file Constant.h.

References m_value.

Member Function Documentation

◆ eval()

template<typename T>
T Pyston::Constant< T >::eval ( const Context & ,
const Arguments &  ) const
inlinefinalvirtual

Evaluate the computing tree

In principle one could avoid to pass any values here, and assign directly the final value to the placeholders that were used to create this tree. However, this would cause the placeholders not to be thread-safe, and a tree would have to be either cloned, either protected by a mutex. Passing the values as an argument allows making the full tree immutable once built, and fully thread safe.

Returns
Result of the evaluation
Note
Obviously this node does nothing with the arguments

Implements Pyston::Node< T >.

Definition at line 53 of file Constant.h.

References m_value.

◆ repr()

template<typename T>
std::string Pyston::Constant< T >::repr ( ) const
inlinefinalvirtual

Returns
A human readable representation of the node
Note
It should not include the representation of the children, if any. That's what visitors are for.

Implements Pyston::NodeBase.

Definition at line 44 of file Constant.h.

References m_value, and std::to_string().

Here is the call graph for this function:

◆ visit()

template<typename T>
void Pyston::Constant< T >::visit ( Visitor & visitor) const
inlinefinalvirtual

Entry point for the visitor

Implements Pyston::NodeBase.

Definition at line 60 of file Constant.h.

Member Data Documentation

◆ m_value

template<typename T>
T Pyston::Constant< T >::m_value
private

Definition at line 66 of file Constant.h.

Referenced by Constant(), eval(), and repr().


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