If I understand your question correctly, I think you can do it:
template<size_t size> struct overflow{ operator char() { return size + 256; } };
The sizeof(CComObject<Type>) value sizeof(CComObject<Type>) will be printed as warning messages at compile time.
Check out this little demo: http://www.ideone.com/Diiqy
Check out these posts (from the link above):
prog.cpp: in the member function 'Overflow :: operator char () [with unsigned int size = 4u ]:
prog.cpp: In the member function 'Overflow :: operator char () [with unsigned int size = 12u ]:
prog.cpp: In the member function 'Overflow :: operator char () [with unsigned int size = 400u ]:
In Visual Studio, you can see these messages on the Assembly Output tab; it may not appear in the Error List> Alerts list.
The idea is taken from my other solution:
Calculating and printing factorial during compilation in C ++
source share