Skip to content

Instantly share code, notes, and snippets.

@mjm522
Created March 22, 2022 09:27
Show Gist options
  • Save mjm522/b0c78d6698a653beb75a1d0d53c6a916 to your computer and use it in GitHub Desktop.
Save mjm522/b0c78d6698a653beb75a1d0d53c6a916 to your computer and use it in GitHub Desktop.
Wrapping a template-d function in pybind11
T* constructOrFindInstance(const std::string& instance_name)
{
auto result = mSegment.find<T>(instance_name.c_str());
if (result.first != nullptr) {
return result.first;
} else {
return mSegment.construct<T>(instance_name.c_str())();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment