pair:该数据结构里有两种数据类型
trio:该数据结构里有三种数据类型
test.cpp如下
#include <iostream>
#include <assert.h>
#include "utility.h"
using namespace std;
typedef Pair<int, char>Pair_ic;
typedef Trio<int, int, char>Trio_iic;
Pair_ic p0;
Trio_iic t0;
class Int{
int val;
public:
Int(int v)
: val(v){}
bool operator == (Int x) const
{ return !(val < x.val) && ! (x.val < val);}
bool operator < (Int x) const
{ return val < x.val;}
};
void test_trio(){
Trio_iic p1 = t0, p2(3, 4, 'a');
assert(p1.first == 0);
assert(p1.second == 0);
assert(p2.first == 3);
assert(p2.second == 4);
assert(p2.third == 'a');
assert(p2 == Make_trio(3, 4, 'a'));
assert(p2 < Make_trio(4, 4, 'a'));
assert(p2 < Make_trio(3, 4, 'b'));
assert(p1 != p2);
assert(p2 > p1);