mpusz / mp-units

The quantities and units library for C++
https://mpusz.github.io/mp-units/
MIT License
1.07k stars 85 forks source link

Put the math functions in the same namespace as the units #433

Closed BenFrantzDale closed 1 year ago

BenFrantzDale commented 1 year ago

For types that are math-like, I am in the habit of putting operators like abs in the same namespace so they are found by ADL if I do the std::swap two-step as in

template <typename T>
[[nodiscard]] auto myGenericFunction(T x) {
    using std::abs;
    x = abs(x); // Finds std::abs for T == double, but finds abs by ADL otherwise.
    ...

Having them in ::units::math breaks that, and there's not really a solution in generic code.

BenFrantzDale commented 1 year ago

I must have been mistaken. They are in the same namespace 🤦 https://github.com/mpusz/units/blob/master/src/core/include/units/math.h