Skip to content

[Auto-Sync] Translate templates to functions and not macros #2135

@Rot127

Description

@Rot127

Currently C++ template functions are translated to macros:

template<int targ>
void func() {
   return targ;
}

becomes

#define DEFINE_func(targ) \
   void func_##targ() { \
   return targ; \
}

This is helpful, because targ can also be a type. Also it mimics the sematic closer.

On the other hand it leads to many many duplicated functions and is bad for general obj file size.
Also it is annoying to debug (you cannot set breakpoints in macros).

The CppTranslator should instead generate the templates as functions and pass the template arguments via additional parameter.

The edge case of template<typename T> must be handled somehow.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions