Calico
|
A lens that scales the value by a factor before storing or accessing it. More...
#include <lens.hpp>
Public Types | |
typedef Factor | factor_type |
The type of the factor to be multiplied. | |
typedef Lens | internal_type |
The type of the lens being wrapped. | |
typedef T | value_type |
The value type accepted by the lens. | |
Public Member Functions | |
scaling_lens (internal_type &&data, factor_type &&factor) | |
Wraps a lens. | |
internal_type | data () |
Returns the internal lens. | |
const internal_type & | data () const |
Returns the internal lens. | |
const factor_type & | factor () const |
Returns the factor to be multiplied. | |
operator value_type () const | |
Gets the value through the lens. | |
scaling_lens< Lens, Factor, T > & | operator%= (const value_type &x) |
Modulo assignment through the lens. | |
scaling_lens< Lens, Factor, T > & | operator&= (const value_type &x) |
Bitwise AND assignment through the lens. | |
scaling_lens< Lens, Factor, T > & | operator*= (const value_type &x) |
Multiplication assignment through the lens. | |
scaling_lens< Lens, Factor, T > & | operator++ () |
Pre-increments through the lens. | |
scaling_lens< Lens, Factor, T > & | operator+= (const value_type &x) |
Addition assignment through the lens. | |
scaling_lens< Lens, Factor, T > & | operator-- () |
Pre-decrements through the lens. | |
scaling_lens< Lens, Factor, T > & | operator-= (const value_type &x) |
Subtraction assignment through the lens. | |
scaling_lens< Lens, Factor, T > & | operator/= (const value_type &x) |
Division assignment through the lens. | |
scaling_lens< Lens, Factor, T > & | operator<<= (const value_type &x) |
Bitwise left shift assignment through the lens. | |
scaling_lens & | operator= (const value_type &x) |
Puts a value through the lens. | |
scaling_lens & | operator= (value_type &&x) |
Puts a value through the lens (rvalue version). | |
scaling_lens< Lens, Factor, T > & | operator>>= (const value_type &x) |
Bitwise right shift assignment through the lens. | |
scaling_lens< Lens, Factor, T > & | operator^= (const value_type &x) |
Bitwise XOR assignment through the lens. | |
scaling_lens< Lens, Factor, T > & | operator|= (const value_type &x) |
Bitwise OR assignment through the lens. | |
A lens that scales the value by a factor before storing or accessing it.
If L
is the scaling_lens
, x
is the internal lens, and k
is the factor to be multiplied, the following relationships are satisfied:
L == x / k L = c <==> x = c * k