Tomographer  v5.3
Tomographer C++ Framework Documentation
Tomographer::Tools::StaticOrDynamic< T_, IsDynamic_, StaticValue_ > Class Template Reference

A type which stores a value possibly known at compile-time. More...

#include <tomographer/tools/cxxutil.h>

+ Inheritance diagram for Tomographer::Tools::StaticOrDynamic< T_, IsDynamic_, StaticValue_ >:

Public Types

typedef T_ T
 Type of the value we are storing.
 

Public Member Functions

 StaticOrDynamic ()
 Default Constructor. Only if the value is stored at compile-time.
 
 StaticOrDynamic (T val)
 Constructor with an explicit value. More...
 
T value () const
 Get the value stored. More...
 
T operator() () const
 Get the value stored. More...
 

Static Public Attributes

static constexpr bool IsDynamic = IsDynamic_
 Whether this value is flexible at run-time (dynamic), or fixed at compile-time (static)
 
static constexpr T StaticValue = StaticValue_
 The value, if stored at compile-time.
 

Detailed Description

template<typename T_, bool IsDynamic_, T_ StaticValue_ = T_()>
class Tomographer::Tools::StaticOrDynamic< T_, IsDynamic_, StaticValue_ >

A type which stores a value possibly known at compile-time.

This is an implementation inspired by Eigen's mechanism of compile-time known matrix/vector sizes.

This class declares a private member property which stores a dynamic value given to the constructor, except if a value was already given as template parameter in which case we take for granted that this value will always be the one we want at runtime.

Template Parameters
T_the type of the value to store.
IsDynamic_whether to store a dynamical value, or to store the static, fixed compile-time value.
StaticValue_to store at compile-time. This value will be ignored if IsDynamic is false.

Definition at line 152 of file cxxutil.h.

Constructor & Destructor Documentation

§ StaticOrDynamic()

template<typename T_, bool IsDynamic_, T_ StaticValue_ = T_()>
Tomographer::Tools::StaticOrDynamic< T_, IsDynamic_, StaticValue_ >::StaticOrDynamic ( T  val)
inlineexplicit

Constructor with an explicit value.

The value val must equal the compile-time fixed value, if any, or you'll get an assert failure.

Definition at line 173 of file cxxutil.h.

Member Function Documentation

§ operator()()

template<typename T_, bool IsDynamic_, T_ StaticValue_ = T_()>
T Tomographer::Tools::StaticOrDynamic< T_, IsDynamic_, StaticValue_ >::operator() ( ) const
inline

Get the value stored.

The same call syntax works both for dynamic and compile-time storage.

Definition at line 188 of file cxxutil.h.

§ value()

template<typename T_, bool IsDynamic_, T_ StaticValue_ = T_()>
T Tomographer::Tools::StaticOrDynamic< T_, IsDynamic_, StaticValue_ >::value ( ) const
inline

Get the value stored.

The same call syntax works both for dynamic and compile-time storage.

Definition at line 182 of file cxxutil.h.


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