language: C++ 4.7.2 (gcc-4.7.2)
date: 331 days 23 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
 
template <class Ty1, class Ty2>
class Pair
{
public:
        typedef Ty1 first_type;
        typedef Ty2 second_type;
        
        first_type first;
        second_type second;
        
        Pair(Ty1, Ty2);
};
 
template <class Ty1, class Ty2>
Pair<Ty1, Ty2>::Pair(Ty1 f, Ty2 s)
: first(f), second(s)
{}
 
template <class Ty1, class Ty2>
Pair<Ty1, Ty2> make_pair(Ty1 f, Ty2 s)
{
        return Pair<Ty1, Ty2>(f, s);
}
 
int main()
{
        Pair<int, float> foo = make_pair(42, 3.14f);
 
        std::cout << "First: " << foo.first << std::endl;
        std::cout << "Second: " << foo.second << std::endl;
 
        return 0;
}