rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
Loading...
Searching...
No Matches
Public Member Functions | List of all members
rexlib::scalar_value Class Reference

Owns a copy of a dynamically typed scalar value. More...

#include <rexlib/core/numerical/scalar_value.hpp>

Public Member Functions

template<typename T >
 scalar_value (const T &value) noexcept
 Construct a new scalar value object holding a copy of the input.
 
 scalar_value (const scalar_value &other)=default
 
 scalar_value (scalar_value &&other)=default
 
scalar_value & operator= (const scalar_value &other)=default
 
scalar_value & operator= (scalar_value &&other)=default
 
template<typename T >
const T & get () const
 Type-safe access to the stored value.
 
template<typename T >
const T * get_if () const noexcept
 Type-safe, non-throwing access to the stored value.
 
numerical_type get_data_type () const noexcept
 Get the numerical type of the stored value.
 

Detailed Description

Owns a copy of a dynamically typed scalar value.

The scalar value must be representable by one of the numerical_type types. Unlike a reference, this class stores the value in-place, so it does not depend on the lifetime of the object it was constructed from.

Constructor & Destructor Documentation

◆ scalar_value()

template<typename T >
rexlib::scalar_value::scalar_value ( const T &  value)
noexcept

Construct a new scalar value object holding a copy of the input.

Template Parameters
TType of the value. It must be representable by a numerical_type.
Parameters
valueThe value to be copied.

Member Function Documentation

◆ get()

template<typename T >
const T & rexlib::scalar_value::get ( ) const

Type-safe access to the stored value.

Template Parameters
TType to be accessed.
Returns
const T& Reference to the stored value.
Exceptions
bad_scalar_value_accessif T does not match the stored type.

◆ get_data_type()

numerical_type rexlib::scalar_value::get_data_type ( ) const
noexcept

Get the numerical type of the stored value.

Returns
numerical_type The numerical type.

◆ get_if()

template<typename T >
const T * rexlib::scalar_value::get_if ( ) const
noexcept

Type-safe, non-throwing access to the stored value.

Template Parameters
TType to be accessed.
Returns
const T* Pointer to the stored value, or nullptr if T does not match the stored type.

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