Created
March 22, 2022 09:27
-
-
Save mjm522/b0c78d6698a653beb75a1d0d53c6a916 to your computer and use it in GitHub Desktop.
Wrapping a template-d function in pybind11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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