C ++模板模板参数类型推导
我有在字符串容器中查找并打印出模式匹配项的代码。在模板化的函数foo中执行打印 编码 #include <iostream> #include <algorithm> #include <iterator> #include <vector> #include <string> #include <tuple> #include <utility> template<typename Iterator, template<typename> class Container> void foo(Iterator first, Container<std::pair<Iterator, Iterator>> const &findings) { for (auto const &finding : findings) { std::cout << "pos = " << std::distance(first, finding.first) << " "; std::copy(finding.first, finding.second, std::ostream_iterator<char>(std::cout)); …