Tensor Comprehensions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tc::ValueAccessor< T > Class Template Reference

#include <mapping_options.h>

Public Types

using Setter = std::function< void(T)>
 
using Getter = std::function< T()>
 

Public Member Functions

 ValueAccessor (const Setter &s, const Getter &g)
 
 ValueAccessor (const ValueAccessor &)=default
 
 operator T () const
 
ValueAccessoroperator= (const T &t)
 

Private Attributes

Setter setter_
 
Getter getter_
 

Detailed Description

template<typename T>
class tc::ValueAccessor< T >

Simple template class to wrap getters and by-value setters. Instances of this class can be implicitly converted to the template parameter type by calling the provided getter function. They can be assigned from an instance of the template parameter type by calling the setter function provided in the constructor.

Note that this class does not in any sense extend the lifetime of the accessed object. Make sure that getters and setters actually change the object, e.g., capture by-reference in lambdas.

Member Typedef Documentation

template<typename T>
using tc::ValueAccessor< T >::Getter = std::function<T()>
template<typename T>
using tc::ValueAccessor< T >::Setter = std::function<void(T)>

Constructor & Destructor Documentation

template<typename T>
tc::ValueAccessor< T >::ValueAccessor ( const Setter s,
const Getter g 
)
inline
template<typename T>
tc::ValueAccessor< T >::ValueAccessor ( const ValueAccessor< T > &  )
default

Member Function Documentation

template<typename T>
tc::ValueAccessor< T >::operator T ( ) const
inline
template<typename T>
ValueAccessor& tc::ValueAccessor< T >::operator= ( const T &  t)
inline

Member Data Documentation

template<typename T>
Getter tc::ValueAccessor< T >::getter_
private
template<typename T>
Setter tc::ValueAccessor< T >::setter_
private

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