OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [docs/] [html/] [23_containers/] [wrappers_h.txt] - Blame information for rev 20

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 20 jlechner
 
2
/*****************************************************************
3
 * Functions to help treat arrays in a uniform manner.  These were
4
 * inspired by a thread on comp.lang.c++.moderated, started by Dietmar
5
 * Kuehl and contributed to by the rest of the entire planet.
6
 *
7
 * beginof (x), endof (x), lengthof (x) now accompany sizeof, where x
8
 * can be either a container (currently only sequences) or a builtin
9
 * array (/not/ a pointer).  The beginof/endof are intended for use in
10
 * the algorithms library, and lengthof is a "sizing" function.
11
 *
12
 * Note example:
13
 *       char  an_array [17];
14
 *       cerr << lengthof(an_array) << endl;
15
 * produces assembly code of
16
 *       mov 17,register0
17
 *       call ofstream_put
18
 * i.e., the template function inlining really does work; g++
19
 * requires -O3 (or -finline-functions) before it does this, though.
20
 *
21
 * pedwards 13Nov98
22
*/
23
// beginof
24
template 
25
  inline typename vector::iterator beginof (vector &v)
26
  { return v.begin(); }
27
 
28
template 
29
  inline T* beginof (T (&array)[sz]) { return array; }
30
 
31
 
32
// endof
33
template 
34
  inline typename vector::iterator endof (vector &v)
35
  { return v.end(); }
36
 
37
template 
38
  inline T* endof (T (&array)[sz]) { return array + sz; }
39
 
40
 
41
// lengthof
42
template 
43
  inline typename vector::size_type lengthof (vector &v)
44
  { return v.size(); }
45
 
46
template 
47
  inline unsigned int lengthof (T (&)[sz]) { return sz; }
48
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.