Is there a way to get an unsigned equivalent (same size) of a signed integral type in C++? I'm thinking along the lines of:
template<typename T>
struct get_unsigned { };
template<>
struct get_unsigned<int> {
typedef unsigned int type;
};
...
template<typename T>
void myfunc(T val) {
get_unsigned<T>::type u = std::abs(val);
...
}
I'm looking for an existing solution in the standard library or Boost and prefer not to roll my own unless it's a handful of lines.