It’s possible to write a `template<typename T> MakeUnsigned`

containing a member `typedef`

that does that. C++11 `<type_traits>`

has `std::make_unsigned`

that does exactly this, and nothing in it requires C++11. I imagine we’ll pick it up at some point, too, in `mozilla/TypeTraits.h`

.

There’s no particular reason to use `const T t`

except (perhaps) extra clarity about the parameter not being modified.

template<typename T> unsigned T Abs(T t) { return t >= 0 ? (unsigned T)t : (unsigned T)(-1 ^ t) + 1; }

(I hope this works, given that there’s no preview…)

(Side note: why do you need const T t when T is a primitive type?)

]]>`abs`

functions return the signed type may find this Stack Overflow question informative.
]]>