Skip to content

Commit

Permalink
cpp: support generic parameters
Browse files Browse the repository at this point in the history
Effectively this adds the 'typename' keyword in multiple places throughout
the generated code. This is a requirement of C++ if the types in a type trait
depend on template arguments. This is one of the many peculiarities of C++ ...
  • Loading branch information
cmnrd committed Aug 19, 2021
1 parent 69ae865 commit 115029c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ class CppParameterGenerator(private val reactor: Reactor) {
/** Get a C++ type that is a const reference to the parameter type */
val Parameter.constRefType: String
get() =
"std::add_lvalue_reference<std::add_const<$targetType>::type>::type"
"typename std::add_lvalue_reference<typename std::add_const<$targetType>::type>::type"
}

/** Generate all parameter declarations */
fun generateDeclarations() =
reactor.parameters.joinToString("\n", "// parameters\n", "\n") {
"std::add_const<${it.targetType}>::type ${it.name};"
"typename std::add_const<${it.targetType}>::type ${it.name};"
}

/** Generate all constructor initializers for parameters */
Expand Down

0 comments on commit 115029c

Please sign in to comment.