diff --git a/src/Type.cc b/src/Type.cc index 85600e349d..fd05c82c3e 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1209,7 +1209,7 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name, AddNameInternal(module_name, name, val, is_export); if ( vals.find(val) == vals.end() ) - vals[val] = IntrusivePtr{AdoptRef{}, new EnumVal(this, val)}; + vals[val] = make_intrusive(this, val); set types = BroType::GetAliases(GetName()); set::const_iterator it; @@ -1265,7 +1265,7 @@ IntrusivePtr EnumType::GetVal(bro_int_t i) if ( it == vals.end() ) { - rval = IntrusivePtr{AdoptRef{}, new EnumVal(this, i)}; + rval = make_intrusive(this, i); vals[i] = rval; } else diff --git a/src/Val.h b/src/Val.h index 3aa128c5f6..95a687709c 100644 --- a/src/Val.h +++ b/src/Val.h @@ -998,6 +998,9 @@ protected: friend class Val; friend class EnumType; + template + friend IntrusivePtr make_intrusive(Ts&&... args); + EnumVal(EnumType* t, int i) : Val(bro_int_t(i), t) { }