Allow .as<Rep>()
syntax on a Quantity
#256
Labels
⬇️ affects: code (interfaces)
Affects the way end users will interact with the library
📁 kind: enhancement
New feature or request
💪 effort: medium
With the introduction of
Constant
, there was an API introduced for those that allows theRep
to be indicated without changing theUnit
of the constant. Specifically, one can use.as<Rep>()
to return aQuantity
with the desiredRep
from aConstant
.I find this to be a natural API, and often find myself trying to do the same thing on a
Quantity
when I want aQuantity
with a specificRep
. We have several other options when this needs to be done:.coerce_as<Rep>(Unit)
.as<Rep>(Unit)
rep_cast<Rep>(Quantity)
The first one is scary. The second option works, but forces me know the
Unit
even if I don't want theUnit
to change. The third option is does astatic_cast
on the underlying value. I think the third option is best suited for my use cases.What I'm thinking is an API that is
.as<Rep>()
if I don't want the unit to change, with as much of the "don't accidentally shoot yourself in the foot" checking as the library can provide.The text was updated successfully, but these errors were encountered: