As mentioned in the other answers, templates are evaluated at compile time. If you're interested you can have g++ spit out the class hierarchy where you can verify its size:
template <class T, int _size>
class CArray
{
public:
private:
T m_data[_size];
};
int main(int argc, char **argv) {
CArray<int, 32> myStupidArray1;
CArray<int, 8> myStupidArray2;
CArray<int, 64> myStupidArray3;
CArray<int, 1000> myStupidArray4;
}
Compile with -fdump-class-hierarchy
:
g++ -fdump-class-hierarchy blah.cc
There should be a file named blah.cc.t01.class
in the current directory:
Class CArray<int, 32>
size=128 align=4
base size=128 base align=4
CArray<int, 32> (0x40be0d80) 0
Class CArray<int, 8>
size=32 align=4
base size=32 base align=4
CArray<int, 8> (0x40be0e80) 0
Class CArray<int, 64>
size=256 align=4
base size=256 base align=4
CArray<int, 64> (0x40be0f80) 0
Class CArray<int, 1000>
size=4000 align=4
base size=4000 base align=4
CArray<int, 1000> (0x40be6000) 0