An explicit instantiation declaration (an extern template) skips implicit instantiation step: the code that would otherwise cause an implicit instantiation instead uses the explicit instantiation definition provided elsewhere (resulting in link errors if no such instantiation exists). This can be used to reduce compilation times by explicitly declaring a template instantiation in all but one of the source files using it, and explicitly defining it in the remaining file. |
I now read that the advice from the people who are in charge of the C++ language is that 'interface and implementation' programming should be kept strictly separate, which I take to mean as going back to old '.h' for definitions and '*.cpp' for declarations... |
#include "*.tpp"
dodge if you really want to separate them physically while you are writing them. It is a real shame that use of 'export' which the "Comeau' programming language offered did not take off and make it into the standard as it sounds like it would have solved the problem properly. Never mind!... the committee considered the question of whether to deprecate, remove, or leave in the “export template” feature. For context, the only reason we’re even considering this is because Edison Design Group (EDG), the only company to ever implement export, is recommending export be removed or deprecated. Recall that back in the 1990s the committee originally voted the feature in over EDG’s objections in the first place, then in the late 1990s and early 2000s EDG graciously and gallantly went on to invest enormous effort to implement the feature in order to conform to the standard, and so the committee was loath to punish them again by now removing the feature on them. However, given the passage of time, EDG reports that their experience in the field has been that nearly no one actually uses the feature, and that it would be right (and okay with EDG) to deprecate or remove it. At our previous meeting, the general sentiment was in favor of deprecation only. However, at this meeting EDG reported that they would prefer the feature to be removed rather than just deprecated, because a deprecated feature is still part of the standard and required for conformance. By removing it from C++0x, it removes the maintenance burden of being forced to support export indefinitely to maintain full standards conformance (though of course EDG will continue to support it as an extension in their compiler front end for however long seems right based on their own customers’ demand). The committee agreed, and today voted to remove export entirely from C++0x. The “export” keyword is still reserved for future use, but has no defined meaning in the C++0x standard. https://herbsutter.com/2010/03/13/trip-report-march-2010-iso-c-standards-meeting/ |
See: 'Why can’t I separate the definition of my templates class from its declaration and put it inside a .cpp file?' https://isocpp.org/wiki/faq/templates And: 'Explicit instantiation' http://en.cppreference.com/w/cpp/language/class_template |
struct
reserved word? Can a struct
have member-functions too?
Yes. In a class declaration, the keywords class and struct are synonyms, except that: With the keyword class, the default member-access (and the default base-class-access) is private With the keyword struct, the default member-access (and the default base-class-access) is public |