TBTK
Need a break? Support the development by playing Polarity Puzzles
TBTK::Natural Class Reference

Natural number. More...

#include <Natural.h>

Inheritance diagram for TBTK::Natural:
TBTK::PseudoSerializable

Public Member Functions

 Natural ()
 
constexpr Natural (unsigned int value)
 
 Natural (const std::string &serialization, Serializable::Mode mode)
 
constexpr operator unsigned int () const
 
Naturaloperator= (unsigned int rhs)
 
Naturaloperator+= (const Natural &rhs)
 
Naturaloperator-= (const Natural &rhs)
 
Naturaloperator*= (const Natural &rhs)
 
Naturaloperator/= (const Natural &rhs)
 
Naturaloperator++ ()
 
Natural operator++ (int)
 
Naturaloperator-- ()
 
Natural operator-- (int)
 
std::string serialize (Serializable::Mode mode) const
 

Friends

void to_json (nlohmann::json &j, const Natural &natural)
 
void from_json (const nlohmann::json &j, Natural &natural)
 

Detailed Description

Natural number.

Constructor & Destructor Documentation

◆ Natural() [1/3]

TBTK::Natural::Natural ( )
inline

Constructor.

◆ Natural() [2/3]

constexpr TBTK::Natural::Natural ( unsigned int  value)
inlineconstexpr

Constructor.

Parameters
valueThe value to initilize the Natural number with.

◆ Natural() [3/3]

TBTK::Natural::Natural ( const std::string &  serialization,
Serializable::Mode  mode 
)
inline

Constructs an Index from a serialization string.

Parameters
serializationSerialization string from which to construct the Natural number.
modeMode with which the string has been serialized.

Member Function Documentation

◆ operator unsigned int()

constexpr TBTK::Natural::operator unsigned int ( ) const
inlineconstexpr

Type conversion operator.

◆ operator*=()

Natural& TBTK::Natural::operator*= ( const Natural rhs)
inline

Multiplication assignment operator.

Parameters
rhsThe right hand side.
Returns
The Natural after the multiplication has occured.

◆ operator++() [1/2]

Natural& TBTK::Natural::operator++ ( )
inline

Increment operator.

Returns
The Natural after the increment has occured.

◆ operator++() [2/2]

Natural TBTK::Natural::operator++ ( int  )
inline

Increment operator.

Returns
The Natural before the increment has occured.

◆ operator+=()

Natural& TBTK::Natural::operator+= ( const Natural rhs)
inline

Addition assignment operator.

Parameters
rhsThe right hand side.
Returns
The Natural after the addition has occured.

◆ operator--() [1/2]

Natural& TBTK::Natural::operator-- ( )
inline

Decrement operator.

Returns
The Natural after the decrease has occured.

◆ operator--() [2/2]

Natural TBTK::Natural::operator-- ( int  )
inline

Decrement operator.

Returns
The Natural before the decrease has occured.

◆ operator-=()

Natural& TBTK::Natural::operator-= ( const Natural rhs)
inline

Subtraction assignment operator.

Parameters
rhsThe right hand side.
Returns
The Natural after the subtraction has occured.

◆ operator/=()

Natural& TBTK::Natural::operator/= ( const Natural rhs)
inline

Division assignment operator.

Parameters
rhsThe right hand side.
Returns
The Natural after the division has occured.

◆ operator=()

Natural& TBTK::Natural::operator= ( unsigned int  rhs)
inline

Assignment operator.

Parameters
valueThe value to assign the Natural.
Returns
The Natural after assignment has occured.

◆ serialize()

std::string TBTK::Natural::serialize ( Serializable::Mode  mode) const
inline

Serialize Natural. Note that Natural is PseudoSerializable rather than Serializable. This means that the Serializable interface is implemented non-virtually.

Parameters
modeSerialization mode.
Returns
Serialized string representation of the Natural.

Friends And Related Function Documentation

◆ from_json

void from_json ( const nlohmann::json &  j,
Natural natural 
)
friend

Implements the Nlohmann interface for conversion from json.

Parameters
jThe json input.
naturalThe Natural to convert to.

◆ to_json

void to_json ( nlohmann::json &  j,
const Natural natural 
)
friend

Implements the Nlohmann interface for conversion to json.

Parameters
jThe json output.
naturalThe Natural to convert.

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