A quantity point. More...
#include <intervals.h>
Public Types | |
using | category_base_t = details::WithCategory< Cat > |
using | traits_t = typename category_base_t::traits_t |
Traits of the category. More... | |
template<typename OC , typename Type = void> | |
using | enable_if_compatible_t = std::enable_if_t< category_base_t::template category_compatible_with< OC >(), Type > |
using | point_t = Point< Q, Cat, IV > |
This type. More... | |
Types from the base quantity | |
using | quantity_t = Q |
Quantity the interval is based on. More... | |
using | category_t = typename category_base_t::category_t |
The category this point belongs to. More... | |
using | interval_t = IV |
The interval type corresponding to the unit of this point. More... | |
template<typename R > | |
using | scaled_quantity_t = rescale< quantity_t, R > |
A quantity in the same unit, but possibly a different scale. More... | |
using | value_t = typename quantity_t::value_t |
Type of the stored value. More... | |
using | unit_t = typename quantity_t::unit_t |
Description of the scaled unit. More... | |
using | baseunit_t = typename quantity_t::baseunit_t |
Description of the unscaled unit. More... | |
template<typename OQ , typename OI > | |
using | other_point_t = Point< OQ, category_t, OI > |
A point based on a different quantity but with the same category. More... | |
Public Types inherited from util::quantities::concepts::details::WithCategory< Cat > | |
using | category_t = Cat |
The category of this object. More... | |
using | traits_t = category_traits< category_t > |
Traits of this category. More... | |
Public Member Functions | |
Point ()=default | |
Constructor: value is left uninitialized. More... | |
constexpr | Point (value_t v) |
Constructor: takes a value in the intended representation. More... | |
template<typename... Args> | |
constexpr | Point (Quantity< Args...> const q) |
Constructor: converts from a quantity. More... | |
template<typename PT , typename std::enable_if_t< is_point_v< PT >> * = nullptr> | |
constexpr | Point (PT const p) |
Constructor: converts from another point. More... | |
constexpr quantity_t const & | quantity () const |
Returns the value of the interval as a quantity. More... | |
constexpr | operator value_t () const |
Conversion to the base quantity. More... | |
template<typename PT > | |
constexpr std::enable_if_t < is_point_v< PT >, PT > | convertInto () const |
Convert this interval into the specified one. More... | |
Asymmetric operand arithmetic operations | |
These arithmetic operations take care of preserving the point unit through them. Not all possible (or reasonable) operations are supported yet. Some operations that may be symmetric (like addition of interval) are implemented as free functions rather than methods.
| |
template<typename R > | |
constexpr point_t | operator+ (scaled_quantity_t< R > const delta) const |
template<typename OQ , typename OC > | |
constexpr enable_if_compatible_t < Interval< OQ, OC >, point_t > | operator+ (Interval< OQ, OC > const delta) const |
template<typename R > | |
constexpr point_t | operator- (scaled_quantity_t< R > const delta) const |
Returns the value of this point after subtraction of an interval. More... | |
template<typename OQ , typename OC > | |
constexpr enable_if_compatible_t < Interval< OQ, OC >, point_t > | operator- (Interval< OQ, OC > const delta) const |
Returns the value of this point after subtraction of an interval. More... | |
template<typename R > | |
point_t & | operator+= (scaled_quantity_t< R > const other) |
Add a quantity (possibly converted) to this one. More... | |
template<typename OQ , typename OC > | |
enable_if_compatible_t < Interval< OQ, OC >, point_t & > | operator+= (Interval< OQ, OC > const other) |
Add the other interval (possibly converted) to this point. More... | |
template<typename R > | |
point_t & | operator-= (scaled_quantity_t< R > const other) |
Subtract a quantity (possibly converted) from this one. More... | |
template<typename OQ , typename OC > | |
enable_if_compatible_t < Interval< OQ, OC >, point_t & > | operator-= (Interval< OQ, OC > const other) |
Subtract the other interval (possibly converted) from this point. More... | |
constexpr point_t | operator+ () const |
Returns a point with same value. More... | |
constexpr point_t | operator- () const |
Returns a parity-changed point. More... | |
Comparisons. | |
Comparisons with plain numbers are managed by implicit conversion. More care is needed for quantities. Comparisons between two point instances
Value storage types are compared according to C++ rules. | |
template<typename OQ , typename OI > | |
constexpr enable_if_compatible_t < other_point_t< OQ, OI > , bool > | operator== (other_point_t< OQ, OI > const other) const |
template<typename OQ , typename OI > | |
constexpr enable_if_compatible_t < other_point_t< OQ, OI > , bool > | operator!= (other_point_t< OQ, OI > const other) const |
template<typename OQ , typename OI > | |
constexpr enable_if_compatible_t < other_point_t< OQ, OI > , bool > | operator>= (other_point_t< OQ, OI > const other) const |
template<typename OQ , typename OI > | |
constexpr enable_if_compatible_t < other_point_t< OQ, OI > , bool > | operator> (other_point_t< OQ, OI > const other) const |
template<typename OQ , typename OI > | |
constexpr enable_if_compatible_t < other_point_t< OQ, OI > , bool > | operator<= (other_point_t< OQ, OI > const other) const |
template<typename OQ , typename OI > | |
constexpr enable_if_compatible_t < other_point_t< OQ, OI > , bool > | operator< (other_point_t< OQ, OI > const other) const |
Static Public Member Functions | |
template<typename U > | |
static point_t | castFrom (U value) |
Returns a new point initialized with the specified value. More... | |
Static Public Member Functions inherited from util::quantities::concepts::details::WithCategory< Cat > | |
static constexpr category_t | category () |
Returns an instance of the category of this object. More... | |
static constexpr bool | hasCategoryName () |
Returns whether this category has a name. More... | |
static std::string | categoryName () |
Returns the name of the category of this object. More... | |
template<typename OC > | |
static constexpr bool | same_category_as () |
Returns whether the type OC belongs to category_t . More... | |
template<typename OC > | |
static constexpr bool | same_category_as (OC const &) |
template<typename OC > | |
static constexpr bool | category_compatible_with () |
Returns whether OC has a category compatible with this one. More... | |
template<typename OC > | |
static constexpr bool | category_compatible_with (OC const &) |
A quantity point.
Q | quantity the interval is based on |
Cat | category this point belongs to (NoCategory by default) |
A point shares most of the concepts of a Quantity
, but it interacts only with other points rather than with bare Quantity
objects, with the exception of construction. In this sense, the relation between Point
and Quantity
is similar to the one between Quantity
and its base type (Quantity::value_t
).
In addition, Point
has some interaction with the corresponding Interval
: an interval can be seen as the distance, or difference, between two quantity points.
The point belongs to a category, which is just a tag that prevents different points from being mixed up. Note that intervals do not have a category.
Definition at line 566 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::baseunit_t = typename quantity_t::baseunit_t |
Description of the unscaled unit.
Definition at line 608 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::category_base_t = details::WithCategory<Cat> |
Definition at line 568 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::category_t = typename category_base_t::category_t |
The category this point belongs to.
Definition at line 592 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::enable_if_compatible_t = std::enable_if_t <category_base_t::template category_compatible_with<OC>(), Type> |
Definition at line 577 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::interval_t = IV |
The interval type corresponding to the unit of this point.
Definition at line 595 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::other_point_t = Point<OQ, category_t, OI> |
A point based on a different quantity but with the same category.
Definition at line 612 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::point_t = Point<Q, Cat, IV> |
This type.
Definition at line 582 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::quantity_t = Q |
Quantity the interval is based on.
Definition at line 589 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::scaled_quantity_t = rescale<quantity_t, R> |
A quantity in the same unit, but possibly a different scale.
Definition at line 599 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::traits_t = typename category_base_t::traits_t |
Traits of the category.
Definition at line 571 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::unit_t = typename quantity_t::unit_t |
Description of the scaled unit.
Definition at line 605 of file intervals.h.
using util::quantities::concepts::Point< Q, Cat, IV >::value_t = typename quantity_t::value_t |
Type of the stored value.
Definition at line 602 of file intervals.h.
|
explicitdefault |
Constructor: value is left uninitialized.
|
inlineexplicit |
Constructor: takes a value in the intended representation.
Definition at line 623 of file intervals.h.
|
inline |
Constructor: converts from a quantity.
OQ | type of the quantity |
q | quantity to be converted from |
The quantity is required to be in the same unit as this point (unit scale may differ). The value in q
is converted from its native scale into the one of this point.
Definition at line 636 of file intervals.h.
|
inline |
Constructor: converts from another point.
PT | type of the other point |
p | point to be converted from |
Points are required to be in the same unit (unit scale may differ). The value in p
is converted from its native scale into the one of this point.
Definition at line 650 of file intervals.h.
|
inlinestatic |
Returns a new point initialized with the specified value.
U | type to initialize the quantity with |
value | the value to initialize the point with |
Point
object initialized with value
The value
is cast into value_t
via static_cast()
.
Definition at line 827 of file intervals.h.
|
inline |
Convert this interval into the specified one.
Definition at line 816 of file intervals.h.
|
inlineexplicit |
|
inline |
Definition at line 774 of file intervals.h.
|
inline |
Returns the sum of this point plus an interval (from quantity) (note that addition is not symmetric).
Definition at line 695 of file intervals.h.
|
inline |
Returns the sum of this point plus an interval (note that addition is not symmetric).
Definition at line 702 of file intervals.h.
|
inline |
Returns a point with same value.
Definition at line 739 of file intervals.h.
|
inline |
Add a quantity (possibly converted) to this one.
Definition at line 718 of file intervals.h.
|
inline |
Add the other
interval (possibly converted) to this point.
Definition at line 724 of file intervals.h.
|
inline |
Returns the value of this point after subtraction of an interval.
Definition at line 707 of file intervals.h.
|
inline |
Returns the value of this point after subtraction of an interval.
Definition at line 713 of file intervals.h.
|
inline |
Returns a parity-changed point.
Definition at line 742 of file intervals.h.
|
inline |
Subtract a quantity (possibly converted) from this one.
Definition at line 729 of file intervals.h.
|
inline |
Subtract the other
interval (possibly converted) from this point.
Definition at line 735 of file intervals.h.
|
inline |
Definition at line 794 of file intervals.h.
|
inline |
Definition at line 789 of file intervals.h.
|
inline |
Definition at line 769 of file intervals.h.
|
inline |
Definition at line 784 of file intervals.h.
|
inline |
Definition at line 779 of file intervals.h.
|
inline |
Returns the value of the interval as a quantity.
Definition at line 653 of file intervals.h.