Skip to content

Pybind11 cannot bind the Template? #3534

Discussion options

You must be logged in to vote

You havn't instantiated your template functions.

To explain further the template function in your .cpp file doesn't get compiled until it is 'used' in the same 'compilation unit'.
You can solve this by either putting your template code into the header which is normally what you'd do. Or if you really need the code in the cpp for whatever reason you need to 'explicitly instantiate' the functions for the requirted type.

Best bet to understand this is to use google to learn about this or see this link: https://riptutorial.com/cplusplus/example/28734/explicit-instantiation

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sun1638650145
Comment options

Answer selected by sun1638650145
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants