nholthaus / units

a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies.
http://nholthaus.github.io/units/
MIT License
934 stars 134 forks source link

Question about underlying value access/casting #286

Open yzsolt opened 2 years ago

yzsolt commented 2 years ago

The README mentions unit_t::to<T> and unit_cast<T> for accessing the underlying value as T. However the implementation of these seem to be using static_cast<T> internally, and (due to an unit_t::operator T() I guess?) it works externally too.

Is using static_cast for accessing the underlying value considered non-idiomatic? Are there any pitfalls I should be aware of when using static_cast?