Bug 2943 - Simplify the implementation of ns3::Create
Simplify the implementation of ns3::Create
Status: NEW
Product: ns-3
Classification: Unclassified
Component: core
All All
: P3 enhancement
Assigned To: Peter Barnes
Depends on:
  Show dependency treegraph
Reported: 2018-07-06 11:26 EDT by Matthew Bradbury
Modified: 2018-07-06 11:26 EDT (History)
1 user (show)

See Also:

Patch to simplify ns3::Create (7.37 KB, patch)
2018-07-06 11:26 EDT, Matthew Bradbury
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Bradbury 2018-07-06 11:26:31 EDT
Created attachment 3125 [details]
Patch to simplify ns3::Create

This patch simplifies the implementation of ns3::Create by using variadic templates and perfect forwarding. There are three main advantages:
(1) An arbitrary number of parameters can be passed to the constructor of T without needing to manually specify the overloads
(2) Copying the parameters can be potentially avoided
(3) The documentation of Create is simplified as there is only one entry present for it

This implementation is very similar to that of std::make_unique [1].

[1] https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique#Possible_Implementation