template<typename T>
T getValue(std::array<char, sizeof (T)> bytes) {
T result = 0;
for (char byte : bytes) {
result <<= 8;
result |= byte;
}
return result;
} template<typename T>
T getValue(std::array<char, sizeof (T)> bytes) {
T result = 0;
for (char byte : bytes) {
result <<= 8;
result |= byte;
}
return result;
}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.
check out type traits: http://en.cppreference.com/w/cpp/types and std::enable_if: http://en.cppreference.com/w/cpp/types/enable_if
"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.