Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class T1, class T2, class T3>
- class trio {
- public:
- T1 first;
- T2 second;
- T3 third;
- trio(T1 first, T2 second, T3 third) : trio::first(first), trio::second(second), trio::third(third) {}
- trio() {}
- trio(const trio &a) : first(a.first), second(a.second), third(a.third) {}
- void swap(trio &a) {
- std::swap(first, a.first);
- std::swap(second, a.second);
- std::swap(third, a.third);
- }
- void operator= (const trio a) {
- first = a.first;
- second = a.second;
- third = a.third;
- }
- bool operator== (const trio b) {
- return (first == b.first && second == b.second && third == b.third);
- }
- bool operator!= (const trio b) {
- return (first != b.first || second != b.second || third != b.third);
- }
- bool operator< (const trio a) {
- if(first==a.first) {
- if(second==a.second)
- return (third<a.third);
- return (second<a.second);
- }
- return (first<a.first);
- }
- bool operator> (const trio a) {
- if(first==a.first) {
- if(second==a.second)
- return (third>a.third);
- return (second>a.second);
- }
- return (first>a.first);
- }
- bool operator<= (const trio a) {
- return (trio<T1, T2, T3> (first, second, third)<a || trio<T1, T2, T3> (first, second, third)==a);
- }
- bool operator>= (const trio a) {
- return (trio<T1, T2, T3> (first, second, third)>a || trio<T1, T2, T3> (first, second, third)==a);
- }
- };
- template <class T1, class T2, class T3>
- trio<T1, T2, T3> make_trio(T1 first, T2 second, T3 third) {
- return trio<T1, T2, T3> (first, second, third);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement