diff --git a/src/core/model/ptr.h b/src/core/model/ptr.h --- a/src/core/model/ptr.h +++ b/src/core/model/ptr.h @@ -212,137 +212,14 @@ * * These methods work for any class \c T. * + * \tparam T \explicit The type of class object to create. + * \tparam Args \deduced The types of the constructor arguments. + * \return A Ptr to the newly created \c T. + * * \see CreateObject for methods to create derivatives of ns3::Object */ -/** @{ */ -/** - * \tparam T \explicit The type of class object to create. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (void); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \param [in] a1 The first constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \param [in] a5 The fifth constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \tparam T6 \deduced The type of the sixth constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \param [in] a5 The fifth constructor argument. - * \param [in] a6 The sixth constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \tparam T6 \deduced The type of the sixth constructor argument. - * \tparam T7 \deduced The type of the seventh constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \param [in] a5 The fifth constructor argument. - * \param [in] a6 The sixth constructor argument. - * \param [in] a7 The seventh constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7); -/** @}*/ +template +Ptr Create(Args&&... args); /** * \ingroup ptr @@ -512,52 +389,10 @@ * friend non-member function implementations ************************************************/ -template -Ptr Create (void) -{ - return Ptr (new T (), false); -} - -template -Ptr Create (T1 a1) -{ - return Ptr (new T (a1), false); -} - -template -Ptr Create (T1 a1, T2 a2) -{ - return Ptr (new T (a1, a2), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3) +template +Ptr Create(Args&&... args) { - return Ptr (new T (a1, a2, a3), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4) -{ - return Ptr (new T (a1, a2, a3, a4), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return Ptr (new T (a1, a2, a3, a4, a5), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return Ptr (new T (a1, a2, a3, a4, a5, a6), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) -{ - return Ptr (new T (a1, a2, a3, a4, a5, a6, a7), false); + return Ptr (new T(std::forward(args)...), false); } template