Quote:Original post by bjogio
woa, I didn't know, your solution is a little tricky but if it's the only way to manage this I would implement that. The main problem about my program is that I use a stringstream in my template class and I don't want to #include <sstream> in my .h cause all the .cpp that will use this header will use implicity the <sstream> (that is bad for compilation time and style). Thanks
It's definately an issue. My suggestion is to compartmentalize as much as you can. For example, at one point I was working on writing a toy compiler, in which I had a complex grammar defined using boost::spirit. It was a template heavy piece of work, and had a lot of code that needed to be declared in the class definition. To parse an example file, I had something like:
file_iterator<> begin ( filename );
file_iterator<> end = begin.make_end(); //ugly, but that's how boost does it :-/.
parse( begin , end , evo_grammar( ast_tree ) );
where evo_grammar was the huge and monsterous piece of template mojo. Since this was in my main.cc file, it tacked on 20 seconds to every time I made a change in the overall flow of the program. I solved it by moving this statement out into it's own function. The code became something like:
file_iterator<> begin ( filename );
file_iterator<> end = begin.make_end();
compile_into( begin , end , ast_tree );
Now, the only function that needed to access the evo_grammar class and it's template pile was compile_into, which I placed in it's own source file. This meant that I only had to recompile the template code when there was an actual change to that area. Instead of making public the complex AND template heavy parts of the code, I compartmentalized it into a private section.
Just another possible method for solving related problems.