Reputation: 73
I have been using eclipse for quite some time, but I have only recently used it for c++ programming. It was bunch of fun figuring out how to actual compile c++ on eclipse on my system, but I have figured that out with 100% success, but now I have stumbled upon another annoying issue. I have seen that If i create a class in a header file I can use the nifty tool under the source menu called "implement method" that will take my function declarations from my header file and place them in the source file with a body that is ready to code.
Well today I was messing around with some new code and I needed a template class for what I was working on, but behold when I tried to use this implement method function I find that eclipse tells me that there "no implement file found for one or more methods" and instead creates inline function in my header file (like i really need that!). Is this a bug in eclipse or is there some underlying c++ rule that cannot be avoided? I just dont seem to understand why having my class declration as class foo{};
would work just fine, but having template <typename T> class foo{};
causes this error. I know that this is the only issue becuase if I declare a normal class with just one public function it works, but if i take the same class and declare it as template class I find the error occurs again.
tldr:
eclipse "implement method" will place declared fucntion in header file into source file ready to code if class is declared as class foo{};
but fails if class is declared as template <typename T> class foo{};
Upvotes: 1
Views: 912
Reputation: 1
when I tried to use this implement method function I find that eclipse tells me that there "no implement file found for one or more methods" and instead creates inline function in my header file (like i really need that!). Is this a bug in eclipse or is there some underlying c++ rule that cannot be avoided?
No, it's not a bug, but what you actually needed (as you noticed).
It's finally a c++ rule that template definitions must be seen from the header file.
So there's no source file that can be deduced by Eclipse for a template class.
You can though setup file types for .tcc
or .icc
files as c++ source, and include these from your template class header (I'm not sure if Eclipse is clever enough to place auto implementations there ATM, but I'm pretty sure the usual switching between source and header works with such setup).
Upvotes: 4