STIR  6.3.0
Namespaces
assign.h File Reference

defines the stir::assign function to assign values to different data types More...

#include "stir/type_traits.h"
#include <typeinfo>

Go to the source code of this file.

Namespaces

 stir
 Namespace for the STIR library (and some/most of its applications)
 

Functions

templated functions for assigning values

When writing templated code, it is sometimes not possible to use operator=() for assignment, e.g. when the classes do not support that operator. The assign template tries to alleviate this problem by providing several overloads when the first argument is a (STIR) container.

Usage
assign(x,y); // logically equivalent to x=y;
Design consideration
We could have overloaded operator=() instead, but that would probably lead to surprising conversions.
template<class T , class T2 >
std::enable_if_t<!has_iterator_v< T > > stir::assign (T &x, const T2 &y)
 
template<class T , class T2 >
std::enable_if_t< has_full_iterator_v< T > > stir::assign (T &v, const T2 &y)
 
template<class T , class T2 >
std::enable_if_t< has_iterator_and_no_full_iterator< T >::value > stir::assign (T &v, const T2 &y)
 
void stir::assign (double &x, const int y)
 
void stir::assign (float &x, const int y)
 

Detailed Description

defines the stir::assign function to assign values to different data types

Author
Kris Thielemans