A memory safe implementation is only a bit longer:
template<typename T>
T getValue(std::array<char, sizeof (T)> bytes) {
T result = 0;
for (char byte : bytes) {
result <<= 8;
result |= byte;
}
return result;
}
The reason this works in C++ is because it doesn't have protocols. The operations that T is required to support in order to be a valid type argument to this function are not expressed symbolically; they need to be documented, otherwise you end up with compiler error messages that quickly get unwieldy in more complex scenarios.
In large part, that's the problem the OP is confronted with. When you make these things symbolic and first-class, unless they're extremely complete, you find holes in the system. And when they're very complete, you find yourself overwhelmed by the number and apparent complexity of what should be simple. There's an inherent conflict.
"concepts lite" is a proposal to add syntactic sugar for type traits as well as enhance them a bit.
in general this is how C++ does things now: first add library-level solutions as far as possible, then add language-level syntactic sugar once the usage and implementation is fully understood.
And note that C++ will someday add concepts, so they clearly want to move in a more Swift-like direction. A more even comparison would compare C++ with concepts to Swift.