<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
Post a Comment