libstdc++
|
Because libstdc++ based its implementation of the STL subsections of the library on the SGI 3.3 implementation, we inherited their extensions as well.
They are additionally documented in the online documentation, a copy of which is also shipped with the library source code (in .../docs/html/documentation.html). You can also read the documentation on SGI's site, which is still running even though the code is not maintained.
NB that the following notes are pulled from various comments all over the place, so they may seem stilted.
The identity_element
functions are not part of the C++ standard; SGI provided them as an extension. Its argument is an operation, and its return value is the identity element for that operation. It is overloaded for addition and multiplication, and you can overload it for your own nefarious operations.
As an extension to the binders, SGI provided composition functors and wrapper functions to aid in their creation. The unary_compose
functor is constructed from two functions/functors, f
and g
. Calling operator()
with a single argument x
returns f
(g(x)). The function compose1
takes the two functions and constructs a unary_compose
variable for you.
binary_compose
is constructed from three functors, f
, g1
, and g2
. Its operator()
returns f
(g1(x),g2(x)). The function compose2 takes f, g1, and g2, and constructs the binary_compose
instance for you. For example, if f
returns an int, then
int answer = (compose2(f,g1,g2))(x);
is equivalent to
int temp1 = g1(x); int temp2 = g2(x); int answer = f(temp1,temp2);
But the first form is more compact, and can be passed around as a functor to other algorithms.
As an extension, SGI provided a functor called identity
. When a functor is required but no operations are desired, this can be used as a pass-through. Its operator()
returns its argument unchanged.
select1st
and select2nd
are extensions provided by SGI. Their operator()s
take a std::pair
as an argument, and return either the first member or the second member, respectively. They can be used (especially with the composition functors) to strip data from a sequence before performing the remainder of an algorithm.
The operator()
of the project1st
functor takes two arbitrary arguments and returns the first one, while project2nd
returns the second one. They are extensions provided by SGI.
These three functors are each constructed from a single arbitrary variable/value. Later, their operator()s
completely ignore any arguments passed, and return the stored value.
constant_void_fun's
operator()
takes no argumentsconstant_unary_fun's
operator()
takes one argument (ignored)constant_binary_fun's
operator()
takes two arguments (ignored)The helper creator functions constant0
, constant1
, and constant2
each take a result argument and construct variables of the appropriate functor type.
const _Tp& __gnu_cxx::__median | ( | const _Tp & | __a, |
const _Tp & | __b, | ||
const _Tp & | __c | ||
) |
Find the median of three values.
__a | A value. |
__b | A value. |
__c | A value. |
a
, b
or c
.If {l
,m,n} is some convolution of {a
,b,c} such that l<=m<=n
then the value returned will be m
. This is an SGI extension.
Definition at line 548 of file ext/algorithm.
const _Tp& __gnu_cxx::__median | ( | const _Tp & | __a, |
const _Tp & | __b, | ||
const _Tp & | __c, | ||
_Compare | __comp | ||
) |
Find the median of three values using a predicate for comparison.
__a | A value. |
__b | A value. |
__c | A value. |
__comp | A binary predicate. |
a
, b
or c
.If {l
,m,n} is some convolution of {a
,b,c} such that comp(l,m)
and comp(m,n)
are both true then the value returned will be m
. This is an SGI extension.
Definition at line 582 of file ext/algorithm.
size_t std::_Find_first | ( | ) | const |
Finds the index of the first "on" bit.
size_t std::_Find_next | ( | size_t | __prev | ) | const |
Finds the index of the next "on" bit after prev.
__prev | Where to start searching. |
bitset<_Nb>& std::_Unchecked_flip | ( | size_t | __pos | ) |
These versions of single-bit set, reset, flip, and test are extensions from the SGI version. They do no range checking.
Definition at line 1039 of file bitset.
Referenced by std::flip().
bitset<_Nb>& std::_Unchecked_reset | ( | size_t | __pos | ) |
These versions of single-bit set, reset, flip, and test are extensions from the SGI version. They do no range checking.
Definition at line 1032 of file bitset.
Referenced by std::reset().
bitset<_Nb>& std::_Unchecked_set | ( | size_t | __pos | ) |
These versions of single-bit set, reset, flip, and test are extensions from the SGI version. They do no range checking.
Definition at line 1015 of file bitset.
Referenced by std::set().
bitset<_Nb>& std::_Unchecked_set | ( | size_t | __pos, |
int | __val | ||
) |
constexpr bool std::_Unchecked_test | ( | size_t | __pos | ) | const |
These versions of single-bit set, reset, flip, and test are extensions from the SGI version. They do no range checking.
Definition at line 1046 of file bitset.
Referenced by std::test().
unary_compose<_Operation1, _Operation2> __gnu_cxx::compose1 | ( | const _Operation1 & | __fn1, |
const _Operation2 & | __fn2 | ||
) | [inline] |
An SGI extension .
Definition at line 146 of file ext/functional.
binary_compose<_Operation1, _Operation2, _Operation3> __gnu_cxx::compose2 | ( | const _Operation1 & | __fn1, |
const _Operation2 & | __fn2, | ||
const _Operation3 & | __fn3 | ||
) | [inline] |
An SGI extension .
Definition at line 173 of file ext/functional.
constant_void_fun<_Result> __gnu_cxx::constant0 | ( | const _Result & | __val | ) | [inline] |
An SGI extension .
Definition at line 327 of file ext/functional.
constant_unary_fun<_Result, _Result> __gnu_cxx::constant1 | ( | const _Result & | __val | ) | [inline] |
An SGI extension .
Definition at line 333 of file ext/functional.
constant_binary_fun<_Result,_Result,_Result> __gnu_cxx::constant2 | ( | const _Result & | __val | ) | [inline] |
An SGI extension .
Definition at line 339 of file ext/functional.
pair<_InputIterator, _OutputIterator> __gnu_cxx::copy_n | ( | _InputIterator | __first, |
_Size | __count, | ||
_OutputIterator | __result | ||
) | [inline] |
Copies the range [first,first+count) into [result,result+count).
__first | An input iterator. |
__count | The number of elements to copy. |
__result | An output iterator. |
This is an SGI extension. This inline function will boil down to a call to memmove
whenever possible. Failing that, if random access iterators are passed, then the loop count will be known (and therefore a candidate for compiler optimizations such as unrolling).
Definition at line 122 of file ext/algorithm.
References std::__iterator_category().
void __gnu_cxx::distance | ( | _InputIterator | __first, |
_InputIterator | __last, | ||
_Distance & | __n | ||
) | [inline] |
This is an SGI extension.
Definition at line 105 of file ext/iterator.
References std::__iterator_category().
Referenced by __gnu_cxx::random_sample_n().
_Tp __gnu_cxx::identity_element | ( | std::plus< _Tp > | ) | [inline] |
An SGI extension .
Definition at line 88 of file ext/functional.
_Tp __gnu_cxx::identity_element | ( | std::multiplies< _Tp > | ) | [inline] |
An SGI extension .
Definition at line 94 of file ext/functional.
int __gnu_cxx::lexicographical_compare_3way | ( | _InputIterator1 | __first1, |
_InputIterator1 | __last1, | ||
_InputIterator2 | __first2, | ||
_InputIterator2 | __last2 | ||
) |
memcmp
on steroids.
__first1 | An input iterator. |
__last1 | An input iterator. |
__first2 | An input iterator. |
__last2 | An input iterator. |
memcmp
.The return value will be less than zero if the first range is lexigraphically less than the second, greater than zero if the second range is lexigraphically less than the first, and zero otherwise. This is an SGI extension.
Definition at line 203 of file ext/algorithm.
_Tp __gnu_cxx::power | ( | _Tp | __x, |
_Integer | __n, | ||
_MonoidOperation | __monoid_op | ||
) | [inline] |
This is an SGI extension.
Definition at line 113 of file ext/numeric.
_Tp __gnu_cxx::power | ( | _Tp | __x, |
_Integer | __n | ||
) | [inline] |
This is an SGI extension.
Definition at line 123 of file ext/numeric.
_RandomAccessIterator __gnu_cxx::random_sample | ( | _InputIterator | __first, |
_InputIterator | __last, | ||
_RandomAccessIterator | __out_first, | ||
_RandomAccessIterator | __out_last | ||
) | [inline] |
This is an SGI extension.
Definition at line 390 of file ext/algorithm.
_RandomAccessIterator __gnu_cxx::random_sample | ( | _InputIterator | __first, |
_InputIterator | __last, | ||
_RandomAccessIterator | __out_first, | ||
_RandomAccessIterator | __out_last, | ||
_RandomNumberGenerator & | __rand | ||
) | [inline] |
This is an SGI extension.
Definition at line 413 of file ext/algorithm.
_OutputIterator __gnu_cxx::random_sample_n | ( | _ForwardIterator | __first, |
_ForwardIterator | __last, | ||
_OutputIterator | __out, | ||
const _Distance | __n | ||
) |
This is an SGI extension.
Definition at line 269 of file ext/algorithm.
References __gnu_cxx::distance(), and std::min().
_OutputIterator __gnu_cxx::random_sample_n | ( | _ForwardIterator | __first, |
_ForwardIterator | __last, | ||
_OutputIterator | __out, | ||
const _Distance | __n, | ||
_RandomNumberGenerator & | __rand | ||
) |
This is an SGI extension.
Definition at line 303 of file ext/algorithm.
References __gnu_cxx::distance(), and std::min().
pair<_InputIter, _ForwardIter> __gnu_cxx::uninitialized_copy_n | ( | _InputIter | __first, |
_Size | __count, | ||
_ForwardIter | __result | ||
) | [inline] |
Copies the range [first,last) into result.
__first | An input iterator. |
__count | Length |
__result | An output iterator. |
Like copy(), but does not require an initialized output range.
Definition at line 123 of file ext/memory.
References std::__iterator_category().