example3_simplify_nested_templates.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <vector>
#include <utility>

template<typename T1, typename T2>
using PairVector = std::vector<std::pair<T1, T2>>;

int main() {
    PairVector<int, std::string> vec;

    vec.push_back({1, "One"});
    vec.push_back({2, "Two"});

    for (const auto& item : vec) {
        std::cout << item.first << " : " << item.second << std::endl;
    }

    return 0;
}
Back to template_alias