Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Template methods and non-classtype template parameters
Template methods and non-classtype template parameters [message #1851818] Mon, 18 April 2022 16:10 Go to next message
Marcin Dzieżyc is currently offline Marcin DzieżycFriend
Messages: 2
Registered: April 2022
Junior Member
Greetings!

I'm looking for a way or an example on how to declare a template operation/method without the container class also being a template. Adding a TemplateSignature child has no effect on the code generated in C++. Is there another way to add a template qualifier to a method declaration?

On a similar note, I'm not sure how to declare a non-classtype template parameter (something like N for size of an array in std::array). Out of seemingly fitting entities, TemplateParameter seems to only accept OpaqueExpressions, but those result in the parameter to have a literal type `OpaqueExpression` in the generated code. Is there an accepted way to generate such template parameters?

Best regards.
Re: Template methods and non-classtype template parameters [message #1851906 is a reply to message #1851818] Thu, 21 April 2022 13:55 Go to previous message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 461
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Dear Marcin,

operations with template parameters are currently only supported by the C++ generator, if the class itself has a template signature. Feel free to post a bug, if you think that it should also support operation template signatures.

Concerning your 2nd question: you can add a template parameter to the signature of a class (not a classifier template parameter) and then add an owned parameter to it. For instance, choose "K" of type LiteralInteger.
I did a test with a class that has a classifier template parameter with a DataType T and a LiteralInteger K. In this case, the C++ generator produces
template<class T, int K>
class TPClass {
...
}
...
template<class T, int K>
void TPClass<T, K>::tpOperation() { ... }
Previous Topic:Help on Palette Customization
Next Topic:Creating a new stereotype with a custom cpp codegen behaviour
Goto Forum:
  


Current Time: Thu Apr 25 08:53:03 GMT 2024

Powered by FUDForum. Page generated in 0.03453 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top