How do you handle increasingly long compile times when working with templates?

Posted by Ghita on Programmers See other posts from Programmers or by Ghita
Published on 2012-11-28T17:50:49Z Indexed on 2012/11/28 23:14 UTC
Read the original article Hit count: 255

Filed under:
|
|

I use Visual Studio 2012 and he have cases where we added templates parameters to a class "just" in order to introduce a "seam point" so that in unit-test we can replace those parts with mock objects.

How do you usually introduce seam points in C++: using interfaces and/or mixing based on some criteria with implicit interfaces by using templates parameters also ? One reason to ask this is also because when compiling sometimes a single C++ file (that includes templates files, that could also include other templates) results in an object file being generated that takes in the order of around 5-10 seconds on a developer machine.

VS compiler is also not particularly fast on compiling templates as far as I understand, and because of the templates inclusion model (you practically include the definition of the template in every file that uses it indirectly and possibly re-instantiate that template every time you modify something that has nothing to do with that template) you could have problems with compile times (when doing incremental compiling).

What are your ways of handling incremental(and not only) compile time when working with templates (besides a better/faster compiler :-)).

© Programmers or respective owner

Related posts about c++

Related posts about TDD