[問題] template的語法
請問一下各位
以下是我class中的一個template method
只要傳進 vector, deque或是list就可以運作
但我希望可以限制使用者傳的是
std::vector<FileSystem::Info>
std::deque<FileSystem::Info>
std::list<FileSystem::Info>
之類的
避免使用者傳了
std::vector<std::string>
std::deque<std::string>
std::list<std::string>
之類的東西
請問我語法該如何修改
template<typename T>
void getFiles(T& t)
{
DIR* _dir = opendir(m_name.c_str());
if(_dir==NULL)
return;
while(true)
{
dirent* _dirent = readdir(_dir);
if ((_dirent == NULL) || (_dirent->d_name == NULL))
break;
if(strcmp(_dirent->d_name,"..")==0
|| strcmp(_dirent->d_name,".")==0
|| strcmp(_dirent->d_name,"/")==0
)
continue;
FileSystem::Info _info = this->join(std::string(_dirent->d_name));
t.push_back(_info);
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.250.21.20
→
03/05 22:01, , 1F
03/05 22:01, 1F
推
03/05 22:25, , 2F
03/05 22:25, 2F
→
03/05 22:43, , 3F
03/05 22:43, 3F
→
03/06 01:43, , 4F
03/06 01:43, 4F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 4 篇):
問題
1
4