STL(2)---<ulitiy>
来源:互联网 发布:php在线解密工具 编辑:程序博客网 时间:2024/05/20 07:37
Copyright (c) 1995 by P.J. Plauger.
下面是ulitiy的一些简单的实现和使用
/********************************************************************** * * Copyright (c)2015,WK Studios * * Filename: A.h * * Compiler: GCC vc 6.0 * * Author:WK * * Time: 2015 7 8 * **********************************************************************/#include <iostream>using namespace std;template <class T1,class T2>struct Pair{ typedef T1 first_type; typedef T2 second_typel; Pair():first(T1()),second(T2()){} Pair(const T1 &v1,const T2 &v2) :first(v1),second(v2) {} T1 first; T2 second;};template<class T1,class T2>inline bool operator==(const Pair<T1,T2>&x,const Pair<T1,T2>&y){return (x.first == y.first && x.second == y.second);}template<class T1,class T2>inline bool operator!=(const Pair<T1,T2>&x,const Pair<T1,T2>&y){return !(x==y);}template<class T1,class T2>inline bool operator<(const Pair<T1,T2>&x,const Pair<T1,T2>&y){return (x.first < y.first || !(y.first < x.first) && x.second < y.second);}template<class T1,class T2>inline bool operator>(const Pair<T1,T2>&x,const Pair<T1,T2>&y){return (y<x);}template<class T1,class T2>inline bool operator<=(const Pair<T1,T2>&x,const Pair<T1,T2>&y){return !(x>y);}template<class T1,class T2>inline bool operator>=(const Pair<T1,T2>&x,const Pair<T1,T2>&y){return !(x<y);}template<class T1,class T2>inline Pair<T1,T2> make_Pair(const Pair<T1,T2>&x,const Pair<T1,T2>&y){return Pair<T1,T2>(x,y);}class Int{public:Int(int v=0):val(v){}bool operator==(Int &x){return (val == x.val);}bool operator<(Int &y){return (val <y.val);}private:int val;};namespace rei_pos{template<class T> inline bool operator != (const T&x,const T&y){return !(x==y);}template<class T>inline bool operator >(const T&x,const T&y){return (x>y);}template<class T>inline bool operator<=(const T&x,const T&y){return (!(x>y));}template<class T>inline bool operator>=(const T&x,const T&y){return (!(x<y));}}void Require(bool a){if(!a){cout<<"ERRO!\n";}else{cout<<"Success\n";}}int main(){ Pair<int,char> pr(3,'a'); Pair<int,char> p1; Require(pr.second=='a'); Require(p1 != pr);return 0;}
0 0
- STL(2)---<ulitiy>
- stl-2
- STL(2)
- STL#2
- STL源码剖析(2)
- STL LIST实现 - 2
- STL FunctionObject实现 - 2
- Effective STL 读书笔记 2
- STL实践指南(2)
- stl学习笔记2
- STL杂记(2)
- STL实践指南(2)
- STL--hash_map用法(2)
- STL--string用法(2)
- STL学习笔记2
- STL教程(2)
- 7.2.2(next_permutation--STL)
- STL算法学习2
- Grand Central Dispatch 基础教程:Part 1/2
- i9100 G刷机
- HUNNU 11567 Escaping(最大流)
- HDOJ A + B for you again 1867【KMP】
- Android 网络:基于TCP协议通信,多线程,实现简单的C/S聊天室
- STL(2)---<ulitiy>
- HADOOP生态系统
- 架构师速成-如何高效编程
- C/C++ 数据范围(int ,char long, float,double)
- java.lang.ClassNotFoundException: com.sun.mail.util.MessageRemovedIOException
- Grand Central Dispatch 基础教程:Part 2/2
- HDU2.1.8 小数化分数2
- undefined reference to ...... @GLIBCXX
- ibatis的queyrForList和queryForMap区别