PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use. It provides C++ wrappers for the most popular packet processing engines such as libpcap, Npcap, WinPcap, DPDK, AF_XDP and PF_RING.
The current implementation of PointerVector<T> contains a copy constructor/assignment that does a deep copy of all elements.
The issue is that the element wise copy is done via T* x = new T(*elemIt) which would slice off any polymorphic types held in the vector via a pointer to a base type.
A potential twofold solution can be:
Removal of the copy constructor/assignment of PointerVector<T>, making the class similar to a collection of std::unique_ptr.
Adding a SFINAE enabled clone() method, allowing the copy of the vector provided the base class T provides a clone() method.
The current implementation of
PointerVector<T>
contains a copy constructor/assignment that does a deep copy of all elements.The issue is that the element wise copy is done via
T* x = new T(*elemIt)
which would slice off any polymorphic types held in the vector via a pointer to a base type.A potential twofold solution can be:
PointerVector<T>
, making the class similar to a collection ofstd::unique_ptr
.clone()
method, allowing the copy of the vector provided the base classT
provides aclone()
method.