rippled
Public Types | Public Member Functions | Private Attributes | List of all members
ripple::tagged_integer< Int, Tag > Class Template Reference

A type-safe wrap around standard integral types. More...

Inheritance diagram for ripple::tagged_integer< Int, Tag >:
Inheritance graph
[legend]
Collaboration diagram for ripple::tagged_integer< Int, Tag >:
Collaboration graph
[legend]

Public Types

using value_type = Int
 
using tag_type = Tag
 

Public Member Functions

 tagged_integer ()=default
 

Private Attributes

Int m_value
 

Detailed Description

template<class Int, class Tag>
class ripple::tagged_integer< Int, Tag >

A type-safe wrap around standard integral types.

The tag is used to implement type safety, catching mismatched types at compile time. Multiple instantiations wrapping the same underlying integral type are distinct types (distinguished by tag) and will not interoperate. A tagged_integer supports all the usual assignment, arithmetic, comparison and shifting operations defined for the underlying type

The tag is not meant as a unit, which would require restricting the set of allowed arithmetic operations.

Definition at line 44 of file tagged_integer.h.

Member Typedef Documentation

◆ value_type

template<class Int , class Tag >
using ripple::tagged_integer< Int, Tag >::value_type = Int

Definition at line 59 of file tagged_integer.h.

◆ tag_type

template<class Int , class Tag >
using ripple::tagged_integer< Int, Tag >::tag_type = Tag

Definition at line 60 of file tagged_integer.h.

Constructor & Destructor Documentation

◆ tagged_integer()

template<class Int , class Tag >
ripple::tagged_integer< Int, Tag >::tagged_integer ( )
default

Member Data Documentation

◆ m_value

template<class Int , class Tag >
Int ripple::tagged_integer< Int, Tag >::m_value
private

Definition at line 56 of file tagged_integer.h.