Template Arguments for Generators? #8214
-
Can I use template parameters for a generator? For example, consider the following code:
The template parameters I call the
The generation then fails with several compile errors. I looked in the tutorials and apps to find template argument usage but couldn't find it. I have tried using the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Normally you'd use GeneratorParams instead of template parameters for things like that, but sometimes it is more convenient to use template parameters. I think the problem is that the preprocessor doesn't know about angle brackets, so it sees that as a three-argument macro call, where the arguments are
and if that doesn't work try this:
|
Beta Was this translation helpful? Give feedback.
-
You should really be using a GeneratorParam for something like a channel count. The only reason for it to be a template parameter is if you need the channel count to be constexpr for some other reason (e.g. you call a function written by someone else that's templated on the channel count). However, pressing on, this is a c++ CRTP wart. When you use CRTP like this:
Then names from the base class don't get inherited by default. It's super annoying. For members you typically just add a |
Beta Was this translation helpful? Give feedback.
-
Oh, and replace |
Beta Was this translation helpful? Give feedback.
You should really be using a GeneratorParam for something like a channel count. The only reason for it to be a template parameter is if you need the channel count to be constexpr for some other reason (e.g. you call a function written by someone else that's templated on the channel count).
However, pressing on, this is a c++ CRTP wart. When you use CRTP like this:
Then names from the base class don't get inherited by default. It's super annoying. For members you typically just add a
this->
before them, but your problem is with types that belong to the Generator base class. I think this can be solved with someusing
statements in…