Mbed OS Reference
Loading...
Searching...
No Matches
Bounded< Rep, Min, Max > Struct Template Reference

Restrict values of an integer type to a defined range. More...

#include <Bounded.h>

Public Member Functions

 Bounded (Rep v)
 Construct a bounded integer. More...
 
Rep value () const
 Access the inner value. More...
 

Static Public Member Functions

static Rep min ()
 The left-bound value. More...
 
static Rep max ()
 The right-bound value. More...
 

Static Public Attributes

static const Rep MIN = Min
 The left-bound value. More...
 
static const Rep MAX = Max
 The right-bound value. More...
 

Detailed Description

template<typename Rep, Rep Min, Rep Max>
struct ble::Bounded< Rep, Min, Max >

Restrict values of an integer type to a defined range.

The range is a closed interval that includes its left-bound (Min) and right-bound value (Max).

Template Parameters
RepThe C++ integer type used to represent the values.
MinMinimum value allowed.
MaxMaximum value allowed.

Definition at line 37 of file Bounded.h.

Constructor & Destructor Documentation

◆ Bounded()

Bounded ( Rep  v)

Construct a bounded integer.

If v is out of the range [Min : Max], then if it is less than Min, the value of the bounded integer will be Min. If it greater than Max, then the value of the bounded integer will be Max.

Parameters
vThe value to store.

Definition at line 47 of file Bounded.h.

Member Function Documentation

◆ value()

Rep value ( ) const

Access the inner value.

Returns
The current value.

Definition at line 61 of file Bounded.h.

◆ min()

static Rep min ( )
static

The left-bound value.

Returns
The lowest value that this type can represent

Definition at line 71 of file Bounded.h.

◆ max()

static Rep max ( )
static

The right-bound value.

Returns
The highest value that this type can represent

Definition at line 81 of file Bounded.h.

Field Documentation

◆ MIN

const T MIN = Min
static

The left-bound value.

Definition at line 89 of file Bounded.h.

◆ MAX

const T MAX = Max
static

The right-bound value.

Definition at line 94 of file Bounded.h.