Open
Description
A very common operation when trying to write package which works with unitful quantities is getting the unitless element-type. This is required to find the right eps
or set the tolerance to the correct Number
type. However, I am not sure of a completely generic way to handle this. typeof(first(one(u)))
works well in a pinch, but I am noticing an issue with GPUArray
s which do not have indexing and thus don't have first
defined. So the only way I know of to always get the unitless element type is eltype(u./u)
, which has an extra operation just to grab the type.
Is there a generic function to strip the units off of a type? Some unitless(T)
to get whatever the type of the non-unit part is? That would be a clear way to implement this.