Whilst trying to break introuble
post I came across something which I can not explain.
Enums are used alot in templates and the following struct baffles me
Code:
template<int size>
struct Amount
{
enum{ value = size};
};
Now an enum is just an int or some type which is big enough to hold the value. Is this correct?
See if I do a size of
Code:
...
sizeof(Amount<60>)
...
The result is 1 byte so this got me thinking a char is being used; but if a sizeof is done on Amount<60>::value then 4 bytes is returned (size of an int). This is where I am really confused, the value inside the struct is bigger than the struct itself.
I then give the "size" a bigger value than what a char can hold (Amount<500>) and the same results were returned.
Have I just completely missed something here, or is this correct?
edit:
The results are the same for Kdevelop and Visual Studio so I am therefore assuming that it is correct and I have missed something.
Any ideas?