4 ms·
Nobody, AFAIK. Even with an explicit "export template", it's basically impossible because of of the interaction of all the features of the C and C++ and CPP par
by Quekid5 8y ago
Nobody, AFAIK. Even with an explicit "export template", it's basically impossible because of of the interaction of all the features of the C and C++ and CPP parts of the language.
(Precompiled headers are/were are thing, but they're very brittle. Of course, one assumes you already know this, I'm trying to provide additional exposition.)
People started to use templates for metaprogramming and from that point on the scope for "reuse" of templates isn't really there. (Reusing parsing might be plausible, but it's really difficult because parsing is extremely context-sensitive because of SFINAE, #defines, etc.)
Some might comment that "modules" is "export template" all over again, but this time there are actually 2-3 implementations of 2-3 of the proposals and everyone is confident that the remaining minor problems can be resolved satisfactorily... and they're all exchanging experiences to help each other!
- beached_whale 8y agoI am still not sold on templates. They look like they might help the Google's and Microsoft's but for most code bases they seem to be forcing a dual system of dependencies without much benefit.
- aidenn0 8y agoI think you meant "modules"?
- beached_whale 8y agoYeah I did, oops. Templates are great
- beached_whale 8y agoI meant to type modules
- roel_v 8y ago"Precompiled headers are/were are thing, but they're very brittle." In compilers other than Visual Studio, yes (or so I'm mostly told - I don't have all that much experience with them), but msvc has had them since at least VS6 (late 1990's) when I first started using them, and they work very well and have saved me many, many hours since then. Maybe once or twice I had to delete the pch file in all that time, and that was most likely more of a issue of the GUI mangling the saved internal state than the actual compiler. I've heard pushback against precompiled headers from Unix land for 2 decades, I'm not really sure where it comes from. I have the impression it's mostly cognitive dissonance - 'msvc has it and gcc doesn't, therefore it must be bad because gcc is 'better' than msvc'. It's similar to #pragma once - in use, it's objectively better in every possible way than include guards are, and gcc fanboys still dismissed it back when gcc didn't have them.
- jcelerier 8y agoGCC had PCH for years though. Every semi-large project I do with GCC / Clang gets the PCH treatment, in particular because it's so simple with CMake.
- gpderetta 8y agoFWIW, gcc has had pragma once for ages. On the other hand recently we had issues with MSVC not recognizing that an header and its simlink were the same. GCC and clang had no problems. There is a reason pragma once is not standardized. Defining when to include lines refer to the same file is extremely hard.
- aidenn0 8y agoPrelinkers are dying, but 20 years ago they were the normal way of doing things. 30 years ago, Cfront had to use them because it was relying on existing unix linkers that did not have weak symbol support.