1*404b540aSrobert<?xml version="1.0" encoding="ISO-8859-1"?> 2*404b540aSrobert<!DOCTYPE html 3*404b540aSrobert PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 4*404b540aSrobert "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 5*404b540aSrobert 6*404b540aSrobert<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 7*404b540aSrobert<head> 8*404b540aSrobert <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)" /> 9*404b540aSrobert <meta name="KEYWORDS" content="libstdc++, libstdc++-v3, GCC, g++, STL, SGI" /> 10*404b540aSrobert <meta name="DESCRIPTION" content="SGI extensions preserved in libstdc++-v3." /> 11*404b540aSrobert <meta name="GENERATOR" content="vi and eight fingers" /> 12*404b540aSrobert <title>SGI extensions to the library in libstdc++-v3</title> 13*404b540aSrobert<link rel="StyleSheet" href="../lib3styles.css" type="text/css" /> 14*404b540aSrobert<link rel="Start" href="../documentation.html" type="text/html" 15*404b540aSrobert title="GNU C++ Standard Library" /> 16*404b540aSrobert<link rel="Subsection" href="sgiexts.html" type="text/html" title="Extensions" /> 17*404b540aSrobert<link rel="Bookmark" href="howto.html" type="text/html" title="Extensions" /> 18*404b540aSrobert<link rel="Copyright" href="../17_intro/license.html" type="text/html" /> 19*404b540aSrobert</head> 20*404b540aSrobert<body> 21*404b540aSrobert 22*404b540aSrobert<h1 class="centered"><a name="top">SGI extensions to the library in 23*404b540aSrobertlibstdc++-v3</a></h1> 24*404b540aSrobert 25*404b540aSrobert<p>This page describes the extensions that SGI made to their version of the 26*404b540aSrobert STL subset of the Standard C++ Library. For a time we 27*404b540aSrobert <a href="../faq/index.html#5_3">tracked and imported changes and updates 28*404b540aSrobert from most of the SGI STL</a>, up through their (apparently) final release. 29*404b540aSrobert Their extensions were mostly preserved. 30*404b540aSrobert</p> 31*404b540aSrobert 32*404b540aSrobert<p>They are listed according to the chapters of the library that they 33*404b540aSrobert extend (see <a href="../documentation.html#3">the chapter-specific notes</a> 34*404b540aSrobert for a description). Not every chapter may have extensions, and the 35*404b540aSrobert extensions may come and go. Also, this page is incomplete because the 36*404b540aSrobert author is pressed for time. Check back often; the latest change was on 37*404b540aSrobert $Date: 2009/10/15 17:11:32 $ (UTC). 38*404b540aSrobert</p> 39*404b540aSrobert 40*404b540aSrobert<p>Descriptions range from the scanty to the verbose. You should also check 41*404b540aSrobert the <a href="../documentation.html#4">generated documentation</a> for notes 42*404b540aSrobert and comments, especially for entries marked with '*'. For more complete 43*404b540aSrobert doumentation, see the SGI website. For <em>really</em> complete 44*404b540aSrobert documentation, buy a copy of Matt Austern's book. *grin* 45*404b540aSrobert</p> 46*404b540aSrobert 47*404b540aSrobert<p>Back to the <a href="howto.html">libstdc++-v3 extensions</a>. 48*404b540aSrobert</p> 49*404b540aSrobert 50*404b540aSrobert 51*404b540aSrobert<!-- ####################################################### --> 52*404b540aSrobert<hr /> 53*404b540aSrobert<h3><a name="ch20">Chapter 20</a></h3> 54*404b540aSrobert<p>The <functional> header contains many additional functors and 55*404b540aSrobert helper functions, extending section 20.3. They are implemented in the 56*404b540aSrobert file stl_function.h: 57*404b540aSrobert</p> 58*404b540aSrobert<ul> 59*404b540aSrobert <li><code>identity_element</code> for addition and multiplication. * </li> 60*404b540aSrobert <li>The functor <code>identity</code>, whose <code>operator()</code> 61*404b540aSrobert returns the argument unchanged. * </li> 62*404b540aSrobert <li>Composition functors <code>unary_function</code> and 63*404b540aSrobert <code>binary_function</code>, and their helpers <code>compose1</code> 64*404b540aSrobert and <code>compose2</code>. * </li> 65*404b540aSrobert <li><code>select1st</code> and <code>select2nd</code>, to strip pairs. * </li> 66*404b540aSrobert <li><code>project1st</code> and <code>project2nd</code>. * </li> 67*404b540aSrobert <li>A set of functors/functions which always return the same result. They 68*404b540aSrobert are <code>constant_void_fun</code>, <code>constant_binary_fun</code>, 69*404b540aSrobert <code>constant_unary_fun</code>, <code>constant0</code>, 70*404b540aSrobert <code>constant1</code>, and <code>constant2</code>. * </li> 71*404b540aSrobert <li>The class <code>subtractive_rng</code>. * </li> 72*404b540aSrobert <li>mem_fun adaptor helpers <code>mem_fun1</code> and 73*404b540aSrobert <code>mem_fun1_ref</code> are provided for backwards compatibility. </li> 74*404b540aSrobert</ul> 75*404b540aSrobert<p>20.4.1 can use several different allocators; they are described on the 76*404b540aSrobert main extensions page. 77*404b540aSrobert</p> 78*404b540aSrobert<p>20.4.3 is extended with a special version of 79*404b540aSrobert <code>get_temporary_buffer</code> taking a second argument. The argument 80*404b540aSrobert is a pointer, which is ignored, but can be used to specify the template 81*404b540aSrobert type (instead of using explicit function template arguments like the 82*404b540aSrobert standard version does). That is, in addition to 83*404b540aSrobert</p> 84*404b540aSrobert <pre> 85*404b540aSrobert get_temporary_buffer<int>(5);</pre> 86*404b540aSrobert you can also use 87*404b540aSrobert <pre> 88*404b540aSrobert get_temporary_buffer(5, (int*)0);</pre> 89*404b540aSrobert<p>A class <code>temporary_buffer</code> is given in stl_tempbuf.h. * 90*404b540aSrobert</p> 91*404b540aSrobert<p>The specialized algorithms of section 20.4.4 are extended with 92*404b540aSrobert <code>uninitialized_copy_n</code>. * 93*404b540aSrobert</p> 94*404b540aSrobert<p>Return <a href="howto.html">to the main extensions page</a> or 95*404b540aSrobert <a href="http://gcc.gnu.org/libstdc++/">to the homepage</a>. 96*404b540aSrobert</p> 97*404b540aSrobert 98*404b540aSrobert 99*404b540aSrobert<hr /> 100*404b540aSrobert<h3><a name="ch23">Chapter 23</a></h3> 101*404b540aSrobert<p>A few extensions and nods to backwards-compatibility have been made with 102*404b540aSrobert containers. Those dealing with older SGI-style allocators are dealt with 103*404b540aSrobert elsewhere. The remaining ones all deal with bits: 104*404b540aSrobert</p> 105*404b540aSrobert<p>The old pre-standard <code>bit_vector</code> class is present for 106*404b540aSrobert backwards compatibility. It is simply a typedef for the 107*404b540aSrobert <code>vector<bool></code> specialization. 108*404b540aSrobert</p> 109*404b540aSrobert<p>The <code>bitset</code> class has a number of extensions, described in the 110*404b540aSrobert rest of this item. First, we'll mention that this implementation of 111*404b540aSrobert <code>bitset<N></code> is specialized for cases where N number of 112*404b540aSrobert bits will fit into a single word of storage. If your choice of N is 113*404b540aSrobert within that range (<=32 on i686-pc-linux-gnu, for example), then all 114*404b540aSrobert of the operations will be faster. 115*404b540aSrobert</p> 116*404b540aSrobert<p>There are 117*404b540aSrobert versions of single-bit test, set, reset, and flip member functions which 118*404b540aSrobert do no range-checking. If we call them member functions of an instantiation 119*404b540aSrobert of "bitset<N>," then their names and signatures are: 120*404b540aSrobert</p> 121*404b540aSrobert <pre> 122*404b540aSrobert bitset<N>& _Unchecked_set (size_t pos); 123*404b540aSrobert bitset<N>& _Unchecked_set (size_t pos, int val); 124*404b540aSrobert bitset<N>& _Unchecked_reset (size_t pos); 125*404b540aSrobert bitset<N>& _Unchecked_flip (size_t pos); 126*404b540aSrobert bool _Unchecked_test (size_t pos);</pre> 127*404b540aSrobert<p>Note that these may in fact be removed in the future, although we have 128*404b540aSrobert no present plans to do so (and there doesn't seem to be any immediate 129*404b540aSrobert reason to). 130*404b540aSrobert</p> 131*404b540aSrobert<p>The semantics of member function <code>operator[]</code> are not specified 132*404b540aSrobert in the C++ standard. A long-standing defect report calls for sensible 133*404b540aSrobert obvious semantics, which are already implemented here: <code>op[]</code> 134*404b540aSrobert on a const bitset returns a bool, and for a non-const bitset returns a 135*404b540aSrobert <code>reference</code> (a nested type). However, this implementation does 136*404b540aSrobert no range-checking on the index argument, which is in keeping with other 137*404b540aSrobert containers' <code>op[]</code> requirements. The defect report's proposed 138*404b540aSrobert resolution calls for range-checking to be done. We'll just wait and see... 139*404b540aSrobert</p> 140*404b540aSrobert<p>Finally, two additional searching functions have been added. They return 141*404b540aSrobert the index of the first "on" bit, and the index of the first 142*404b540aSrobert "on" bit that is after <code>prev</code>, respectively: 143*404b540aSrobert</p> 144*404b540aSrobert <pre> 145*404b540aSrobert size_t _Find_first() const; 146*404b540aSrobert size_t _Find_next (size_t prev) const;</pre> 147*404b540aSrobert<p>The same caveat given for the _Unchecked_* functions applies here also. 148*404b540aSrobert</p> 149*404b540aSrobert<p>Return <a href="howto.html">to the main extensions page</a> or 150*404b540aSrobert <a href="http://gcc.gnu.org/libstdc++/">to the homepage</a>. 151*404b540aSrobert</p> 152*404b540aSrobert 153*404b540aSrobert 154*404b540aSrobert<hr /> 155*404b540aSrobert<h3><a name="ch24">Chapter 24</a></h3> 156*404b540aSrobert<p>24.3.2 describes <code>struct iterator</code>, which didn't exist in the 157*404b540aSrobert original HP STL implementation (the language wasn't rich enough at the 158*404b540aSrobert time). For backwards compatibility, base classes are provided which 159*404b540aSrobert declare the same nested typedefs: 160*404b540aSrobert</p> 161*404b540aSrobert <ul> 162*404b540aSrobert <li>input_iterator</li> 163*404b540aSrobert <li>output_iterator</li> 164*404b540aSrobert <li>forward_iterator</li> 165*404b540aSrobert <li>bidirectional_iterator</li> 166*404b540aSrobert <li>random_access_iterator</li> 167*404b540aSrobert </ul> 168*404b540aSrobert<p>24.3.4 describes iterator operation <code>distance</code>, which takes 169*404b540aSrobert two iterators and returns a result. It is extended by another signature 170*404b540aSrobert which takes two iterators and a reference to a result. The result is 171*404b540aSrobert modified, and the function returns nothing. 172*404b540aSrobert</p> 173*404b540aSrobert<p>Return <a href="howto.html">to the main extensions page</a> or 174*404b540aSrobert <a href="http://gcc.gnu.org/libstdc++/">to the homepage</a>. 175*404b540aSrobert</p> 176*404b540aSrobert 177*404b540aSrobert 178*404b540aSrobert<hr /> 179*404b540aSrobert<h3><a name="ch25">Chapter 25</a></h3> 180*404b540aSrobert<p>25.1.6 (count, count_if) is extended with two more versions of count 181*404b540aSrobert and count_if. The standard versions return their results. The 182*404b540aSrobert additional signatures return void, but take a final parameter by 183*404b540aSrobert reference to which they assign their results, e.g., 184*404b540aSrobert</p> 185*404b540aSrobert <pre> 186*404b540aSrobert void count (first, last, value, n);</pre> 187*404b540aSrobert<p>25.2 (mutating algorithms) is extended with two families of signatures, 188*404b540aSrobert random_sample and random_sample_n. 189*404b540aSrobert</p> 190*404b540aSrobert<p>25.2.1 (copy) is extended with 191*404b540aSrobert</p> 192*404b540aSrobert <pre> 193*404b540aSrobert copy_n (_InputIter first, _Size count, _OutputIter result);</pre> 194*404b540aSrobert<p>which copies the first 'count' elements at 'first' into 'result'. 195*404b540aSrobert</p> 196*404b540aSrobert<p>25.3 (sorting 'n' heaps 'n' stuff) is extended with some helper 197*404b540aSrobert predicates. Look in the doxygen-generated pages for notes on these. 198*404b540aSrobert</p> 199*404b540aSrobert <ul> 200*404b540aSrobert <li><code>is_heap</code> tests whether or not a range is a heap.</li> 201*404b540aSrobert <li><code>is_sorted</code> tests whether or not a range is sorted in 202*404b540aSrobert nondescending order.</li> 203*404b540aSrobert </ul> 204*404b540aSrobert<p>25.3.8 (lexigraphical_compare) is extended with 205*404b540aSrobert</p> 206*404b540aSrobert <pre> 207*404b540aSrobert lexicographical_compare_3way(_InputIter1 first1, _InputIter1 last1, 208*404b540aSrobert _InputIter2 first2, _InputIter2 last2)</pre> 209*404b540aSrobert<p>which does... what? 210*404b540aSrobert</p> 211*404b540aSrobert<p>Return <a href="howto.html">to the main extensions page</a> or 212*404b540aSrobert <a href="http://gcc.gnu.org/libstdc++/">to the homepage</a>. 213*404b540aSrobert</p> 214*404b540aSrobert 215*404b540aSrobert 216*404b540aSrobert<hr /> 217*404b540aSrobert<h3><a name="ch26">Chapter 26</a></h3> 218*404b540aSrobert<p>26.4, the generalized numeric operations such as accumulate, are extended 219*404b540aSrobert with the following functions: 220*404b540aSrobert</p> 221*404b540aSrobert <pre> 222*404b540aSrobert power (x, n); 223*404b540aSrobert power (x, n, moniod_operation);</pre> 224*404b540aSrobert<p>Returns, in FORTRAN syntax, "x ** n" where n>=0. In the 225*404b540aSrobert case of n == 0, returns the <a href="#ch20">identity element</a> for the 226*404b540aSrobert monoid operation. The two-argument signature uses multiplication (for 227*404b540aSrobert a true "power" implementation), but addition is supported as well. 228*404b540aSrobert The operation functor must be associative. 229*404b540aSrobert</p> 230*404b540aSrobert<p>The <code>iota</code> function wins the award for Extension With the 231*404b540aSrobert Coolest Name. It "assigns sequentially increasing values to a range. 232*404b540aSrobert That is, it assigns value to *first, value + 1 to *(first + 1) and so 233*404b540aSrobert on." Quoted from SGI documentation. 234*404b540aSrobert</p> 235*404b540aSrobert <pre> 236*404b540aSrobert void iota(_ForwardIter first, _ForwardIter last, _Tp value);</pre> 237*404b540aSrobert<p>Return <a href="howto.html">to the main extensions page</a> or 238*404b540aSrobert <a href="http://gcc.gnu.org/libstdc++/">to the homepage</a>. 239*404b540aSrobert</p> 240*404b540aSrobert 241*404b540aSrobert 242*404b540aSrobert<!-- ####################################################### --> 243*404b540aSrobert 244*404b540aSrobert<hr /> 245*404b540aSrobert<p class="fineprint"><em> 246*404b540aSrobertSee <a href="../17_intro/license.html">license.html</a> for copying conditions. 247*404b540aSrobertComments and suggestions are welcome, and may be sent to 248*404b540aSrobert<a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>. 249*404b540aSrobert</em></p> 250*404b540aSrobert 251*404b540aSrobert 252*404b540aSrobert</body> 253*404b540aSrobert</html> 254