SyDEVS  v0.6.7
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sydevs::identity< U > Class Template Reference

A data type which identifies an item by combining an encapsulated integer-valued index with a dimension supplied by a template parameter. More...

#include <identity.h>

Public Member Functions

constexpr identity ()
 Constructs an invalid identity value. More...
 
constexpr identity (int64 index)
 Constructs an identity value with the specified index. More...
 
constexpr identity (const identity &)=default
 Copy constructor. More...
 
identityoperator= (const identity &)=default
 Copy assignment. More...
 
 identity (identity &&)=default
 Move constructor. More...
 
identityoperator= (identity &&)=default
 Move assignment. More...
 
 ~identity ()=default
 Destructor. More...
 
constexpr bool valid () const
 Returns true if the identity value is valid. More...
 
constexpr int64 index () const
 Returns the internal index. More...
 
identityoperator++ ()
 Increments (prefix) the internal index. More...
 
identity operator++ (int)
 Increments (postfix) the internal index. More...
 
identityoperator-- ()
 Decrements (prefix) the internal index. More...
 
identity operator-- (int)
 Decrements (postfix) the internal index. More...
 
identityoperator+= (int64 rhs)
 Adds rhs to the identity value. More...
 
identityoperator-= (int64 rhs)
 Subtracts rhs from the identity value. More...
 
constexpr const identity operator+ () const
 Returns a copy of the identity value. More...
 
constexpr const identity operator+ (int64 rhs) const
 Returns a new identity value with rhs added. More...
 
constexpr const identity operator- (int64 rhs) const
 Returns a new identity value with rhs subtracted. More...
 
constexpr bool operator== (identity rhs) const
 Returns true if the identity value equals rhs. More...
 
constexpr bool operator!= (identity rhs) const
 Returns true if the identity value does not equal rhs. More...
 
constexpr bool operator< (identity rhs) const
 Returns true if the identity value is less than rhs. More...
 
constexpr bool operator> (identity rhs) const
 Returns true if the identity value is greater than rhs. More...
 
constexpr bool operator<= (identity rhs) const
 Returns true if the identity value is at most rhs. More...
 
constexpr bool operator>= (identity rhs) const
 Returns true if the identity value is at least rhs. More...
 

Static Protected Attributes

static constexpr int64 nan_int64 = std::numeric_limits<int64>::min()
 

Detailed Description

template<typename U>
class sydevs::identity< U >

A data type which identifies an item by combining an encapsulated integer-valued index with a dimension supplied by a template parameter.

An identity value is essentially a dimensioned integer, where the units are provided by the template parameter U. An simple example of how to instantiate an identity value is below.

class apple_unit;
using apple_id = identity<apple_unit>;
apple_id my_gala_apple(79);

A default-constructed identity value is invalid. For these values, the valid member function returns false and the index member function returns the most negative representable 64-bit signed integer. For valid identity values, the class supports increment and decrement operations, as well as standard plus and minus operators that offset the encapsulated index by an integer.

apple_id(555) + 10 // apple_id(565)
apple_id(555) - 1000 // apple_id(-445)
215 + apple_id(555) // apple_id(770)

Constructor & Destructor Documentation

template<typename U >
constexpr sydevs::identity< U >::identity ( )

Constructs an invalid identity value.

template<typename U >
constexpr sydevs::identity< U >::identity ( int64  index)
explicit

Constructs an identity value with the specified index.

template<typename U>
constexpr sydevs::identity< U >::identity ( const identity< U > &  )
default

Copy constructor.

template<typename U>
sydevs::identity< U >::identity ( identity< U > &&  )
default

Move constructor.

template<typename U>
sydevs::identity< U >::~identity ( )
default

Destructor.

Member Function Documentation

template<typename U >
constexpr int64 sydevs::identity< U >::index ( ) const

Returns the internal index.

template<typename U >
constexpr bool sydevs::identity< U >::operator!= ( identity< U >  rhs) const

Returns true if the identity value does not equal rhs.

template<typename U >
constexpr const identity< U > sydevs::identity< U >::operator+ ( ) const

Returns a copy of the identity value.

template<typename U >
constexpr const identity< U > sydevs::identity< U >::operator+ ( int64  rhs) const

Returns a new identity value with rhs added.

template<typename U >
identity< U > & sydevs::identity< U >::operator++ ( )

Increments (prefix) the internal index.

template<typename U >
identity< U > sydevs::identity< U >::operator++ ( int  )

Increments (postfix) the internal index.

template<typename U >
identity< U > & sydevs::identity< U >::operator+= ( int64  rhs)

Adds rhs to the identity value.

template<typename U >
constexpr const identity< U > sydevs::identity< U >::operator- ( int64  rhs) const

Returns a new identity value with rhs subtracted.

template<typename U >
identity< U > & sydevs::identity< U >::operator-- ( )

Decrements (prefix) the internal index.

template<typename U >
identity< U > sydevs::identity< U >::operator-- ( int  )

Decrements (postfix) the internal index.

template<typename U >
identity< U > & sydevs::identity< U >::operator-= ( int64  rhs)

Subtracts rhs from the identity value.

template<typename U >
constexpr bool sydevs::identity< U >::operator< ( identity< U >  rhs) const

Returns true if the identity value is less than rhs.

template<typename U >
constexpr bool sydevs::identity< U >::operator<= ( identity< U >  rhs) const

Returns true if the identity value is at most rhs.

template<typename U>
identity& sydevs::identity< U >::operator= ( const identity< U > &  )
default

Copy assignment.

template<typename U>
identity& sydevs::identity< U >::operator= ( identity< U > &&  )
default

Move assignment.

template<typename U >
constexpr bool sydevs::identity< U >::operator== ( identity< U >  rhs) const

Returns true if the identity value equals rhs.

template<typename U >
constexpr bool sydevs::identity< U >::operator> ( identity< U >  rhs) const

Returns true if the identity value is greater than rhs.

template<typename U >
constexpr bool sydevs::identity< U >::operator>= ( identity< U >  rhs) const

Returns true if the identity value is at least rhs.

template<typename U >
constexpr bool sydevs::identity< U >::valid ( ) const

Returns true if the identity value is valid.

Member Data Documentation

template<typename U>
constexpr int64 sydevs::identity< U >::nan_int64 = std::numeric_limits<int64>::min()
staticprotected

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