With using
, an alias for a type can be defined and a unit of this type has the same size like an original instantation (1). A template however only weights 1 byte (2).
using aliasOfInt = int;
template<typename T>
struct intWrapper {
using wrappedAliasOfInt = T;
};
int main() {
// (1) --> 4B
std::cout << "sizeof(aliasOfInt) = " << sizeof(aliasOfInt) << std::endl;
// (2) --> 1B
std::cout << "sizeof(intAliasWrapper) = " << sizeof(intWrapper<int>) << std::endl;
}
In (2), is there a real type compiled or why is this only 1B?