c++ stl library 学习(5)
来源:互联网 发布:建党伟业有一天 知乎 编辑:程序博客网 时间:2024/06/06 02:28
Numeric Limits
old :#include<limits.h> or #include <climits>
standard : #include <limits>
Class numeric_limits
Auxiliary Functions:in #include<algorithm> min 、max、 swap
namespace std {
template <class T>
inline const T& min (const T& a, const T& b) {
return b < a ? b : a;
}
template <class T>
inline const T& max (const T& a, const T& b) {
return a < b ? b : a;
}
}
namespace std {
template <class T, class Compare>
inline const T& min (const T& a, const T& b, Compare comp) {
return comp(b,a) ? b : a;
}
template <class T, class Compare>
inline const T& max (const T& a, const T& b, Compare comp) {
return comp(a,b) ? b : a;
}
}//comp为函数或者伪函数指针
must type match,参数类型要一致。。in min或max。
namespace std {
template<class T>
inline void swap(T& a, T& b) {
T tmp(a);
a = b;
b = trap;
}
}
在c++中经常要用到的c的标准库 #include <cstddef> 和#include <cstdlib>
Note thatin C, NULL often is defined as (void*)0. This is incorrect in C++ because there the type of NULL must be an integer type
c中NULL被定义为(void*)0,但c++中不是这样的,它必须是int类型的,
The exit() and abort() functions are provided to terminate a program in any function without
going back to main():
• exit() destroys all static objects, flushes all buffers, closes all I/O channels, and
terminates the program (including calling atexit() functions). If functions passed to
atexit() throw exceptions, terminate() is called.
• abort() terminates a program immediately with no clean up.
None of these functions destroys local objects because no stack unwinding occurs. To ensure
that the destructors of all local objects are called, you should use exceptions or the ordinary
return mechanism to return to and exit main().
- c++ stl library 学习(5)
- c++ stl library 学习(1)
- c++ stl library 学习(2)
- c++ stl library 学习(3)
- c++ stl library 学习(4)
- c++ stl library 学习(6)
- c++ stl library 学习(7)
- c++ stl library 学习(8)
- c++ stl library 学习(9)
- C Runtime Library 与 STL
- 标准模板库(Standard Template Library,STL)学习
- STL(Standard Template Library)
- C++STL学习(5)容器map和multimap
- C++STL学习(10)STL算法(1)
- C++STL学习(11)STL算法(2)
- C++STL学习(1)容器vector
- C++STL学习(2)容器deque
- C++STL学习(3)容器list
- cocos2d-x学习之二:cocos2d-x之CCUserDefault使用
- HttpServletResponse的应用
- Cannot copy file. The Parameter Is Incorrect
- 非printf形式打印各种数据类型的十六进制和二进制
- 指针函数和函数指针的区别
- c++ stl library 学习(5)
- Servlet的中文输出问题
- android:installLocation简析
- android 设置文字样式
- web地址的写法分析
- 强化VB.NET编程多线程句柄技巧
- 通过开始关键字和结束关键字,查找所有的邮箱名称记录
- 把VMware VMX格式转换成OVF模版
- Java 利用 HttpURLConnection 读取页面 返回字节流(生成静态页面)