To get that code to link a with the -fno-implicit-templates there are
two explicit instantiation that you need to do (although, I think one of then is not necessary. see below...)
The following compiles, links and runs..
#include <iostream>
#include <vector>
//using namespace std;
struct TCbDoubleBridgeBase_Candidates
{
public:
int I;
int J;
//
TCbDoubleBridgeBase_Candidates(int AI, int AJ)
{
I=AI;
J=AJ;
};
inlinebooloperator < (const TCbDoubleBridgeBase_Candidates &other) const
{
int i=I-other.I;
//
if (i<0)
returntrue;
elseif (i==0)
return J<other.J;
elsereturnfalse;
}
};
template <typename T>
class CMain
{
public:
CMain()
{
data.reserve(100);
}
std::vector<T> data;
};
//explicit instantiations
templateclass CMain<TCbDoubleBridgeBase_Candidates>; //the straightforward one - I'm not sure you need this one to be explicit
templateclass std::vector<TCbDoubleBridgeBase_Candidates>; //you will need this one though..
int main()
{
CMain<TCbDoubleBridgeBase_Candidates> cs;
}
//You could put the explicit instantiations here instead of before main if you prefer
Does it work on your computer?
In my one refuses int both cases (4.5.3 under cygwin and 4.7.2 under kubuntu)
output for cygwin:
$ gcc -fno-implicit-templates ex.cpp
/tmp/ccm9LSKx.o:ex.cpp:(.text+0x4a): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccm9LSKx.o:ex.cpp:(.text+0x65): undefined reference to `std::ios_base::Init::~Init()'
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: /tmp/ccm9LSKx.o: bad reloc address 0xd in section `.text$_ZN5CMainI30TCbDoubleBridgeBase_CandidatesED1Ev[CMain<TCbDoubleBridgeBase_Candidates>::~CMain()]'
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: final link failed: Invalid operation
...
To be honest - the way I would figure out a situation like this would be to:
make sure the thing build completely without the -fno-implicit-templates option.
Then build with the -fno-implicit-templates option.
Any items that suddenly go MIA are the one that you need to
explicitly instantiate.
EDIT
((For the record I tried both G++ 3.4.5 and G++ 4.6.2 using codeblocks on windows
and although they gave sliglty different results, the issue of std::ios didn't come
up - it might well depends on what other baggage your ide/build system automatically includes ))