【发布时间】:2014-02-12 12:27:33
【问题描述】:
我编写了一个函数来迭代list、vector 或字符串上带有iterator 的任何内容,并且该函数在字符串上返回一对相同类型的容器......
我写了以下,但我没有编译,我尝试将容器类型捕获为 C,并将分配器捕获为 A。
重要的是,我只使用 C++98。
template<template<std::string, A> class C, class A>
static std::pair<T<std::string, A>, T<std::string, A> > Check(const T<std::string, A>::iterator &beg, const T<std::string, A>::iterator &end)
{
//....
}
调用我使用的代码:
vector<string> toCheck; toCheck += "test1", "test2";
pair<vector<string>, vector<string> > found = Check(toCheck.begin(), check.end());
您知道如何编写该函数吗?
【问题讨论】:
标签: c++ templates c++98 type-deduction