我有一个任意 STL 容器 C,其中包含任意类型 T 的元素。我想创建一个 std::vector,它具有所有元素的副本。最干净的方法是什么?
template <typename C>
void myfunction(C container){
/*Derive the type T of elements within the container*/
std::vector<T> mystack;
/* Iterate over container and push_back() the elements into mystack*/
}