Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can control code generation for templates by putting only the generic data structures in the header, and all function bodies in an implementation file. Then you explicitly instantiate the template for the types you want it for in that implementation file, and declare those instantiations as forward references in the header.

It's not pretty, but it's not hard either, and gives you full control over how many instances there are around. When C++ is used in a heavily constrained environment, that can come in handy.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: