Skip to content

Generate bindings to explicitly instantiated function templates #492

Open
@fitzgen

Description

@fitzgen

We can't invoke the C++ compiler to generate new instantiations of templates, so I don't think we even try to keep track of them currently.

However, we could track explicit instantiations of template functions (14.7.2 in the standard) and make bindings to those.

For example, if given

template<class T> void foo(T t) { /∗ ... ∗/ }
template void foo(char);
template void foo(int);

We could generate something like:

extern "C" {
    #[link_name = "..."]
    pub fn foo_char(char);

    #[link_name = "..."]
    pub fn foo_int(int);
}

But either way, we can't create new template instantiations, so we shouldn't even try to generate bindings to generic functions based on the template, or to instantiations for which we haven't seen an explicit instantiation.

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