May-be a template function:
This won't work with signed types, though, because the result would be seen as -1 in either case, and the implicit cast from -1L to -1LL would flip the rest of the bits.
template <class N>
unsigned long long a = all_ones<unsigned long>();
unsigned long long b = all_ones<unsigned long long>();
std::cout << std::hex << a << '\n' << b << '\n';
However, it also appears to me that you might just want to divide 2.0 by the maximum value of corresponding unsigned type:
Be warned that you could lose some precision with unsigned long long, since its maximum value might not be exactly representable as double.
double d = 2.0 / std::numeric_limits<unsigned long>::max();