wrappers_h.txt

来自「俄罗斯高人Mamaich的Pocket gcc编译器(运行在PocketPC上)」· 文本 代码 · 共 49 行

TXT
49
字号
/***************************************************************** * Functions to help treat arrays in a uniform manner.  These were * inspired by a thread on comp.lang.c++.moderated, started by Dietmar * Kuehl and contributed to by the rest of the entire planet. * * beginof (x), endof (x), lengthof (x) now accompany sizeof, where x * can be either a container (currently only sequences) or a builtin * array (/not/ a pointer).  The beginof/endof are intended for use in * the algorithms library, and lengthof is a "sizing" function. * * Note example: *       char  an_array [17]; *       cerr << lengthof(an_array) << endl; * produces assembly code of *       mov 17,register0 *       call ofstream_put * i.e., the template function inlining really does work; g++ * requires -O3 (or -finline-functions) before it does this, though. * * pedwards 13Nov98*/// beginoftemplate <class T>  inline typename vector<T>::iterator beginof (vector<T> &v)  { return v.begin(); }template <class T, unsigned int sz>  inline T* beginof (T (&array)[sz]) { return array; }// endoftemplate <class T>  inline typename vector<T>::iterator endof (vector<T> &v)  { return v.end(); }template <class T, unsigned int sz>  inline T* endof (T (&array)[sz]) { return array + sz; }// lengthoftemplate <class T>  inline typename vector<T>::size_type lengthof (vector<T> &v)  { return v.size(); }template <class T, unsigned int sz>  inline unsigned int lengthof (T (&)[sz]) { return sz; }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?