Book a Demo

Author Topic: Code Generation of templated class  (Read 3861 times)

AdamC

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Code Generation of templated class
« on: February 16, 2007, 08:15:01 am »
I've been trying to generate a templated class. The header file is created correctly but none of the implementaions of any operations get generated. Moreover the generation of the .cpp file doesn't happen at all.
The other thing I would like to generate is specialisations of particular operations given a particular instance of the templated class. Any ideas would be appreciated thanks.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Code Generation of templated class
« Reply #1 on: February 16, 2007, 10:20:39 am »
Try the Search function of this forum. Search for the phrase "template class" (without the quotes) and go back 999 days to be sure you get lots of stuff. Search all sections except Latest News. [I also set the option to search posts by all posters, but the default may produce the same results.]

If this does not provide the information you need, please provide more specific information.
No, you can't have it!

AdamC

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Code Generation of templated class
« Reply #2 on: February 19, 2007, 12:00:51 am »
Thanks for the pointer to search but I had already failed to find anything.

I am using the C++ code generation templates, when I generate a templated class only the .h is generated.


If there is an implementation of an operation (which would have ended up in a .cpp), all I get is the operation declaration.

Hope this helps to clarify.

sl@sh

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
Re: Code Generation of templated class
« Reply #3 on: February 20, 2007, 05:57:08 am »
I am a new EA user myself, so I'm afraid I can't give any specific help on this issue just yet. However, there's two pieces of advice that might be helpful:

1. start with some C++ code of the kind and style you want, import it, look at the results, export it to another location, look at the differences. This might help in getting some insight into EA code generation

2. I wouldn't expect C++ template implementations to be generated into a .cpp file. Since at compile time a one-pass compiler will not know the template parameters used within the project by the time it tries to compile the template implementation file, it will not compile anything at all! I'm not sure whether the C++ standard makes any assumptions about this, but I know for a fact that at least some compilers will not handle this correctly. For this reason the standard location for template implementations is usually a header file. The EA code generation templates allow for a lot of customizing, and perhaps this is where you need to take a look at when you want your implementations to be placed elsewhere, but the default templates almost certainly will not generate template implementations into a .cpp file, for the above reason.