<sizeof(T)> as inherited class template parameter in c++ -


i've been trying make transition simple self-made game engine written in c c++ , came across nice book mike mcshaffry (game coding complete). , love of bios almighty cannot wrap head around 'optional template class', namely piece of code:

class optional_empty { };  template <unsigned long size> class optional_base { public:      // code here };  template <class t> class optional : public optional_base<sizeof(t)> { public:      // code here }; 

why 'sizeof(t)' used template parameter when inheriting, , not plain 't'? make possible have t's of dynamic size? there no 'sizeof...' operator, it's not related variadic templates. or it? thanks.

because optional_base not expecting template type parameter template value parameter (of type unsigned long).


Comments

Popular posts from this blog

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -

Qt4: how to send QString inside a struct via QSharedMemory -

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -