#include <string>
#include <deque>
#include <list>
#include <vector>
#include <iostream>
template < template<typename ...> class Container, typename ...Types>
void function(const Container<std::string, Types...>& container) {
for(const std::string& s: container) {
std::cout << s << " ";
}
std::cout << std::endl;
}
int main () {
std::deque<std::string> d{ "Hello", "Deque" };
function(d);
std::list<std::string> l{ "Hello", "List" };
function(l);
std::vector<std::string> v{ "Hello", "Vector" };
function(v);
function(std::vector<int>());
return 0;
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGRlcXVlPgojaW5jbHVkZSA8bGlzdD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGUgPCB0ZW1wbGF0ZTx0eXBlbmFtZSAuLi4+IGNsYXNzIENvbnRhaW5lciwgdHlwZW5hbWUgLi4uVHlwZXM+CnZvaWQgZnVuY3Rpb24oY29uc3QgQ29udGFpbmVyPHN0ZDo6c3RyaW5nLCBUeXBlcy4uLj4mIGNvbnRhaW5lcikgewogICAgZm9yKGNvbnN0IHN0ZDo6c3RyaW5nJiBzOiBjb250YWluZXIpIHsKICAgICAgICBzdGQ6OmNvdXQgPDwgcyA8PCAiICI7CiAgICB9CiAgICBzdGQ6OmNvdXQgPDwgc3RkOjplbmRsOwp9CgppbnQgbWFpbiAoKSB7CiAgICBzdGQ6OmRlcXVlPHN0ZDo6c3RyaW5nPiBkeyAiSGVsbG8iLCAiRGVxdWUiIH07CiAgICBmdW5jdGlvbihkKTsKICAgIHN0ZDo6bGlzdDxzdGQ6OnN0cmluZz4gbHsgIkhlbGxvIiwgIkxpc3QiIH07CiAgICBmdW5jdGlvbihsKTsKICAgIHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiB2eyAiSGVsbG8iLCAiVmVjdG9yIiB9OwogICAgZnVuY3Rpb24odik7CiAgICBmdW5jdGlvbihzdGQ6OnZlY3RvcjxpbnQ+KCkpOwogICAgcmV0dXJuIDA7Cn0=
prog.cpp: In function ‘int main()’:
prog.cpp:22:32: error: no matching function for call to ‘function(std::vector<int>)’
function(std::vector<int>());
^
prog.cpp:22:32: note: candidate is:
prog.cpp:8:6: note: template<template<class ...> class Container, class ... Types> void function(const Container<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Types ...>&)
void function(const Container<std::string, Types...>& container) {
^
prog.cpp:8:6: note: template argument deduction/substitution failed:
prog.cpp:22:32: note: mismatched types ‘std::basic_string<char>’ and ‘int’
function(std::vector<int>());
^