Does using template in C ++ use some kind of task initialization?

Before using some of C ++ 's features for kernel development, there is some work to be done. For example, to use classes effectively, you must execute procedures to call constructors and destructor properties.

Other features that are not needed can be disabled, such as RTTI (Runtime Information).

Does it take extra work to use templates, assuming the classes are working correctly?

+3


source to share


1 answer


I think the main problem is writing code at runtime to handle the stack to handle exceptions. The kernel and the compiler must agree on the details of the calling convention, such as the structure of the stack, and how destructors are registered, discovered, and called.

And if you want to support exception handling, then you (essentially) need to enable RTTI, because C ++ semantics catch

does dynamic type mapping.



Memory allocation can be another problem. new

quite natural, but if you have a weird one kmalloc

with extra options (like Linux) then it might take some thought.

Templates and the placement of calls to constructors and destructors (other than exception handling) are completely handled by the compiler, so you need to "just work".

+3


source







All Articles