mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-19 09:25:51 +00:00
Use no-destructor idiom for type_caster_odr_guard_registry, as suggested by @laramiel
This commit is contained in:
parent
671c2ce0d5
commit
696b80a59b
@ -28,9 +28,12 @@
|
||||
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
||||
PYBIND11_NAMESPACE_BEGIN(detail)
|
||||
|
||||
inline std::unordered_map<std::type_index, std::string> &type_caster_odr_guard_registry() {
|
||||
static std::unordered_map<std::type_index, std::string> reg;
|
||||
return reg;
|
||||
using type_caster_odr_guard_registry_type = std::unordered_map<std::type_index, std::string>;
|
||||
|
||||
inline type_caster_odr_guard_registry_type &type_caster_odr_guard_registry() {
|
||||
// Using the no-destructor idiom (maximizes safety).
|
||||
static auto reg = new type_caster_odr_guard_registry_type();
|
||||
return *reg;
|
||||
}
|
||||
|
||||
inline unsigned &type_caster_odr_violation_detected_counter() {
|
||||
|
Loading…
Reference in New Issue
Block a user