diff --git a/include/verilated_types.h b/include/verilated_types.h index 7670e8d16..c046536bf 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -1931,36 +1931,26 @@ public: VlClassRef(VlNull) {}; template VlClassRef(VlDeleter& deleter, T_Args&&... args) - // () required here to avoid narrowing conversion warnings, - // when a new() has an e.g. CData type and passed a 1U. : m_objp{new T_Class} { + // Instantly init the object to presevrve RAII m_objp->init(std::forward(args)...); - // refCountInc was moved to the constructor of T_Class - // to fix self references in constructor. m_objp->m_deleterp = &deleter; } VlClassRef(VlDeleter& deleter, T_Class&& args) - // () required here to avoid narrowing conversion warnings, - // when a new() has an e.g. CData type and passed a 1U. + // Move constructor : m_objp{new T_Class{std::forward(args)}} { - // refCountInc was moved to the constructor of T_Class - // to fix self references in constructor. m_objp->m_deleterp = &deleter; } - VlClassRef(VlDeleter& deleter, const T_Class&& args) - // () required here to avoid narrowing conversion warnings, - // when a new() has an e.g. CData type and passed a 1U. - : m_objp{new T_Class{std::forward(args)}} { - // refCountInc was moved to the constructor of T_Class - // to fix self references in constructor. + VlClassRef(VlDeleter& deleter, const T_Class& args) + // Copy constructor + : m_objp{new T_Class{args}} { m_objp->m_deleterp = &deleter; } - VlClassRef(VlDeleter& deleter, T_Class args) - // () required here to avoid narrowing conversion warnings, - // when a new() has an e.g. CData type and passed a 1U. - : m_objp{new T_Class{std::move(args)}} { - // refCountInc was moved to the constructor of T_Class - // to fix self references in constructor. + VlClassRef(VlDeleter& deleter, T_Class& args) + // Copy constructor - this is required since if `T_Class&` + // will be provided a compilator will match it to the constructor + // with variading template inetead of `T_Class&&` + : m_objp{new T_Class{args}} { m_objp->m_deleterp = &deleter; } // Explicit to avoid implicit conversion from 0