Simulant  21.06-50
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
Public Member Functions | List of all members
smlt::RangeValue< min, max, T > Class Template Reference

#include <range_value.h>

Public Member Functions

 RangeValue (T x)
 
 RangeValue (const RangeValue &rhs)
 
RangeValueoperator= (const RangeValue &rhs)
 
 operator T () const
 
bool operator== (const RangeValue &rhs) const
 
bool operator!= (const RangeValue &rhs) const
 

Detailed Description

template<int min, int max, typename T = float>
class smlt::RangeValue< min, max, T >

Lots of methods have arguments which must be clamped to a range. Using a 'float' or 'int' doesn't convey that via the API, and it means every method must do its own clamping. This template class allows you to specify a range (and type) for arguments and automatically clamps to the range. e.g.

void set_some_value(RangeValue<0, 1> value);

or

void set_some_byte(RangeValue<0, 255, uint8_t> value);

Now it's clear what the value should be.


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