rippled
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
xrpl::tagged_integer< Int, Tag > Class Template Reference

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

#include <tagged_integer.h>

Inheritance diagram for xrpl::tagged_integer< Int, Tag >:
Inheritance graph
[legend]
Collaboration diagram for xrpl::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 xrpl::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 26 of file tagged_integer.h.

Member Typedef Documentation

◆ value_type

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

Definition at line 39 of file tagged_integer.h.

◆ tag_type

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

Definition at line 40 of file tagged_integer.h.

Constructor & Destructor Documentation

◆ tagged_integer()

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

Member Data Documentation

◆ m_value

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

Definition at line 36 of file tagged_integer.h.