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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libstdc++-v3/] [doc/] [xml/] [manual/] [utilities.xml] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
2
3
 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"
4
[ ]>
5
 
6
7
8
 
9
10
  
11
    
12
      ISO C++
13
    
14
    
15
      library
16
    
17
  
18
19
 
20
</code></pre></td>
      </tr>
      <tr valign="middle">
         <td>21</td>
         <td></td>
         <td></td>
         <td class="code"><pre><code>  Utilities</code></pre></td>
      </tr>
      <tr valign="middle">
         <td>22</td>
         <td></td>
         <td></td>
         <td class="code"><pre><code>  <indexterm><primary>Utilities</primary></indexterm></code></pre></td>
      </tr>
      <tr valign="middle">
         <td>23</td>
         <td></td>
         <td></td>
         <td class="code"><pre><code>
24
 
25
26
27
28
  Functors
29
   If you don't know what functors are, you're not alone.  Many people
30
      get slightly the wrong idea.  In the interest of not reinventing
31
      the wheel, we will refer you to the introduction to the functor
32
      concept written by SGI as chapter of their STL, in
33
      their
34
      http://www.sgi.com/tech/stl/functors.html.
35
   
36
37
 
38
39
40
41
  Pairs
42
   The pair<T1,T2> is a simple and handy way to
43
      carry around a pair of objects.  One is of type T1, and another of
44
      type T2; they may be the same type, but you don't get anything
45
      extra if they are.  The two members can be accessed directly, as
46
      .first and .second.
47
   
48
   Construction is simple.  The default ctor initializes each member
49
      with its respective default ctor.  The other simple ctor,
50
   
51
   
52
    pair (const T1& x, const T2& y);
53
   
54
   does what you think it does, first getting x
55
      and second getting y.
56
   
57
   There is a copy constructor, but it requires that your compiler
58
      handle member function templates:
59
   
60
   
61
    template <class U, class V> pair (const pair<U,V>& p);
62
   
63
   The compiler will convert as necessary from U to T1 and from
64
      V to T2 in order to perform the respective initializations.
65
   
66
   The comparison operators are done for you.  Equality
67
      of two pair<T1,T2>s is defined as both first
68
      members comparing equal and both second members comparing
69
      equal; this simply delegates responsibility to the respective
70
      operator== functions (for types like MyClass) or builtin
71
      comparisons (for types like int, char, etc).
72
   
73
   
74
      The less-than operator is a bit odd the first time you see it.  It
75
      is defined as evaluating to:
76
   
77
   
78
    x.first  <  y.first  ||
79
        ( !(y.first  <  x.first)  &&  x.second  <  y.second )
80
   
81
   The other operators are not defined using the rel_ops
82
      functions above, but their semantics are the same.
83
   
84
   Finally, there is a template function called make_pair
85
      that takes two references-to-const objects and returns an
86
      instance of a pair instantiated on their respective types:
87
   
88
   
89
    pair<int,MyClass> p = make_pair(4,myobject);
90
   
91
 
92
93
 
94
95
96
97
  Memory
98
  
99
    Memory contains three general areas. First, function and operator
100
    calls via new and delete
101
    operator or member function calls.  Second, allocation via
102
    allocator. And finally, smart pointer and
103
    intelligent pointer abstractions.
104
  
105
 
106
  
107
  
108
              parse="xml" href="allocator.xml">
109
  
110
 
111
  
112
  
113
              parse="xml" href="auto_ptr.xml">
114
  
115
 
116
  
117
  
118
              parse="xml" href="shared_ptr.xml">
119
  
120
 
121
122
 
123
124
125
126
  Traits
127
  
128
  
129
130
 
131

powered by: WebSVN 2.1.0

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