> > Some compilers really compile it. > > It compiles fine. It just doesn't link.
My fault, sorry. I mean, it links. > > > VC71, BCB 2006 > > It works. > > I have no clue what 'BCB 2006' is, but VC71 fails to link it just > like most of the other compilers: You are right, the code doesn't link with VC71 either. I cannot answer offhand, why my more complicated library still is compiling on VC71 ( I thought my small example matches the big case ). I have to analyse this. But BCB2006 DOES, I swear ;) (Of course, I know, that G++ is the much more STANDARD complient compiler. Therefore, I am using it...) > > If g++ does not generate the code for "foo<bool>::notUsed()", how does > > g++ know that "doFunc<bool>()" is needed. > > But g++ *is* generating the code (because you asked it to): Yes, that's the problem. I didn't expect a compiler to generate the code, because it's inline. I thought it's generated when it is used in code only, not by an explicit template instantiation. I am exporting code to a library, therefore the explicit instantiation! The inline code does not have to be explicitely instantiated and exported.> > Instantiating "foo<bool>::notUsed()" would instantiate > > "doFunc<bool>()". Unfortunatelly, "doFunc<...>()" does not work for > > "bool". Therefore, using "notUsed()" for type "foo<bool>" should be > > prohibited. > > The way to prohibit its instantiation is to provide a specialization > that does not compile (compile-time assert) or that aborts at > runtime. I know, how to do the runtime work, because I implemented it once. However, I think that this isn't the right way. The error should be thrown by compiler (or linker). Let's call "doFunc<....>()" => "doModulo<...>()" (<= not defined for "bool", but for others, of course) e.g. for "int" template <> int computeValueModulo(const int &, const int &) {} And "notUsed()" => "foo<T> &operator(const T&)" (<= should not be explicitely instantiated for foo<bool> therefore) The only way to achieve this is to make an additional class, which is fully specialized, right? Can anybody think about another possibility? > // template class foo<bool>; // <<< BOGUS instantiation request Yes, I need explicit instantiation (because of export). The only thing I wanted in my example is: Do throw an compiler error (maybe linker error), if "notUsed()" IS used for "bool". Thank you for your help Paul!! _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus