引数として標準コンテナー (リスト、スタック、ベクターなど) のいずれかを取ることができる関数を作成しようとしています。コンテナ内の型も知りたいです。これが私が試したことです。
#include<iostream>
#include<list>
#include<vector>
template<class data_type, template<class> class container_type>
void type(container_type<data_type>& _container){
std::cout<<typeid(container_type).name()<<std::endl;
}
int main(){
std::list<int> list_t;
std::vector<int> vector_t;
type(list_t);
type(vector_t);
}
container_type
この関数内の once の型は常に_Container_base_aux_alloc_empty
、標準コンテナの基本クラスであると思います。
ここで何が起こっているのですか?
この関数が正しい型を返すようにするにはどうすればよいですか?