Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- using namespace std;
- // 这种写法只有GCC可以编译通过
- template<typename DataType, template<typename T, typename Alloc = std::allocator<T>> class Container>
- void f1(Container<DataType>& c)
- {
- for (const auto &ele : c) {
- std::cout << ele << " ";
- }
- }
- // 这种写法GCC/Clang都可以编译通过
- template<typename DataType, template<typename...> class Container>
- void f2(Container<DataType>& c)
- {
- for (const auto &ele : c) {
- std::cout << ele << " ";
- }
- }
- int main()
- {
- std::vector<int> vec{1, 2, 3};
- f1(vec);
- f2(vec);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement