Skip to content

Support for non-type template parameters #30

@sturdivant20

Description

@sturdivant20

In my c++ library I have multiple functions with non-type template arguments, e.g.

template <bool do_something = false>
void foo(int &x) {
  ...
  if constexpr (do_something) {
    ...
  }
}

The documentation has a clear method to generate python bindings for c++ functions with a template type. Is this type of templating supported and if so is there a clear method to implement a template argument?

I tried emulating the method for template types with no success

options.fn_template_options.add_specialization("foo", ["true"])
options.fn_template_options.add_specialization("foo", ["do_something=true"])

I end up with errors like

raise SrcmlcppException(f"Could not find a child of type {type_of_cpp_element}")
srcmlcpp.srcmlcpp_exception.SrcmlcppException: Could not find a child of type <class 'srcmlcpp.cpp_types.decls_types.cpp_decl_statement.CppDeclStatement'>

and

assert new_cpp_function is not None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions