---
name: "SGIextensions"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/SGIextensions"
---

# SGIextensions(3)

SGI

## NAME

SGIextensions - SGI

## SYNOPSIS

### Classes

class **\_\_gnu\_cxx::binary\_compose\< \_Operation1, \_Operation2, \_Operation3 \>**\
 An **SGI extension** .  struct **\_\_gnu\_cxx::constant\_binary\_fun\< \_Result, \_Arg1, \_Arg2 \>**\
 An **SGI extension** .  struct **\_\_gnu\_cxx::constant\_unary\_fun\< \_Result, \_Argument \>**\
 An **SGI extension** .  struct **\_\_gnu\_cxx::constant\_void\_fun\< \_Result \>**\
 An **SGI extension** .  class **\_\_gnu\_cxx::hash\_map\< \_Key, \_Tp, \_HashFn, \_EqualKey, \_Alloc \>**\
 class **\_\_gnu\_cxx::hash\_multimap\< \_Key, \_Tp, \_HashFn, \_EqualKey, \_Alloc \>**\
 class **\_\_gnu\_cxx::hash\_multiset\< \_Value, \_HashFcn, \_EqualKey, \_Alloc \>**\
 class **\_\_gnu\_cxx::hash\_set\< \_Value, \_HashFcn, \_EqualKey, \_Alloc \>**\
 struct **\_\_gnu\_cxx::project1st\< \_Arg1, \_Arg2 \>**\
 An **SGI extension** .  struct **\_\_gnu\_cxx::project2nd\< \_Arg1, \_Arg2 \>**\
 An **SGI extension** .  struct **\_\_gnu\_cxx::rb\_tree\< \_Key, \_Value, \_KeyOfValue, \_Compare, \_Alloc \>**\
 class **\_\_gnu\_cxx::rope\< \_CharT, \_Alloc \>**\
 struct **\_\_gnu\_cxx::select1st\< \_Pair \>**\
 An **SGI extension** .  struct **\_\_gnu\_cxx::select2nd\< \_Pair \>**\
 An **SGI extension** .  class **\_\_gnu\_cxx::slist\< \_Tp, \_Alloc \>**\
 class **\_\_gnu\_cxx::subtractive\_rng**\
 struct **\_\_gnu\_cxx::temporary\_buffer\< \_ForwardIterator, \_Tp \>**\
 class **\_\_gnu\_cxx::unary\_compose\< \_Operation1, \_Operation2 \>**\
 An **SGI extension** .

### Functions

template\<typename \_Tp\> const \_Tp & **\_\_gnu\_cxx::\_\_median** (const \_Tp &\_\_a, const \_Tp &\_\_b, const \_Tp &\_\_c)\
 Find the median of three values.  template\<typename \_Tp, typename \_Compare\> 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.  constexpr size\_t **std::bitset\< \_Nb \>::\_Find\_first** () const noexcept\
 Finds the index of the first *on"*bit. constexpr size\_t **std::bitset\< \_Nb \>::\_Find\_next** (size\_t \_\_prev) const noexcept\
 Finds the index of the next *on"*bit*after*prev. template\<class \_Operation1, class \_Operation2\> **unary\_compose**\< \_Operation1, \_Operation2 \> **\_\_gnu\_cxx::compose1** (const \_Operation1 &\_\_fn1, const \_Operation2 &\_\_fn2)\
 An **SGI extension** .  template\<class \_Operation1, class \_Operation2, class \_Operation3\> **binary\_compose**\< \_Operation1, \_Operation2, \_Operation3 \> **\_\_gnu\_cxx::compose2** (const \_Operation1 &\_\_fn1, const \_Operation2 &\_\_fn2, const \_Operation3 &\_\_fn3)\
 An **SGI extension** .  template\<class \_Result\> **constant\_void\_fun**\< \_Result \> **\_\_gnu\_cxx::constant0** (const \_Result &\_\_val)\
 An **SGI extension** .  template\<class \_Result\> **constant\_unary\_fun**\< \_Result, \_Result \> **\_\_gnu\_cxx::constant1** (const \_Result &\_\_val)\
 An **SGI extension** .  template\<class \_Result\> **constant\_binary\_fun**\< \_Result, \_Result, \_Result \> **\_\_gnu\_cxx::constant2** (const \_Result &\_\_val)\
 An **SGI extension** .  template\<typename \_InputIterator, typename \_Size, typename \_OutputIterator\> **std::pair**\< \_InputIterator, \_OutputIterator \> **\_\_gnu\_cxx::copy\_n** (\_InputIterator \_\_first, \_Size \_\_count, \_OutputIterator \_\_result)\
 Copies the range \[first,first+count) into \[result,result+count).  template\<typename \_InputIterator, typename \_Distance\> void **\_\_gnu\_cxx::distance** (\_InputIterator \_\_first, \_InputIterator \_\_last, \_Distance &\_\_n)\
 template\<class \_Tp\> \_Tp **\_\_gnu\_cxx::identity\_element** (**std::multiplies**\< \_Tp \>)\
 An **SGI extension** .  template\<class \_Tp\> \_Tp **\_\_gnu\_cxx::identity\_element** (**std::plus**\< \_Tp \>)\
 An **SGI extension** .  template\<typename \_InputIterator1, typename \_InputIterator2\> int **\_\_gnu\_cxx::lexicographical\_compare\_3way** (\_InputIterator1 \_\_first1, \_InputIterator1 \_\_last1, \_InputIterator2 \_\_first2, \_InputIterator2 \_\_last2)\
 memcmp on steroids.  template\<typename \_Tp, typename \_Integer\> \_Tp **\_\_gnu\_cxx::power** (\_Tp \_\_x, \_Integer \_\_n)\
 template\<typename \_Tp, typename \_Integer, typename \_MonoidOperation\> \_Tp **\_\_gnu\_cxx::power** (\_Tp \_\_x, \_Integer \_\_n, \_MonoidOperation \_\_monoid\_op)\
 template\<typename \_InputIterator, typename \_RandomAccessIterator\> \_RandomAccessIterator **\_\_gnu\_cxx::random\_sample** (\_InputIterator \_\_first, \_InputIterator \_\_last, \_RandomAccessIterator \_\_out\_first, \_RandomAccessIterator \_\_out\_last)\
 template\<typename \_InputIterator, typename \_RandomAccessIterator, typename \_RandomNumberGenerator\> \_RandomAccessIterator **\_\_gnu\_cxx::random\_sample** (\_InputIterator \_\_first, \_InputIterator \_\_last, \_RandomAccessIterator \_\_out\_first, \_RandomAccessIterator \_\_out\_last, \_RandomNumberGenerator &\_\_rand)\
 template\<typename \_ForwardIterator, typename \_OutputIterator, typename \_Distance\> \_OutputIterator **\_\_gnu\_cxx::random\_sample\_n** (\_ForwardIterator \_\_first, \_ForwardIterator \_\_last, \_OutputIterator \_\_out, const \_Distance \_\_n)\
 template\<typename \_ForwardIterator, typename \_OutputIterator, typename \_Distance, typename \_RandomNumberGenerator\> \_OutputIterator **\_\_gnu\_cxx::random\_sample\_n** (\_ForwardIterator \_\_first, \_ForwardIterator \_\_last, \_OutputIterator \_\_out, const \_Distance \_\_n, \_RandomNumberGenerator &\_\_rand)\
 template\<typename \_InputIter, typename \_Size, typename \_ForwardIter\> **std::pair**\< \_InputIter, \_ForwardIter \> **\_\_gnu\_cxx::uninitialized\_copy\_n** (\_InputIter \_\_first, \_Size \_\_count, \_ForwardIter \_\_result)\
 Copies the range \[first,last) into result.  constexpr **bitset**\< \_Nb \> & **std::bitset\< \_Nb \>::\_Unchecked\_set** (size\_t \_\_pos) noexcept\
 constexpr **bitset**\< \_Nb \> & **std::bitset\< \_Nb \>::\_Unchecked\_set** (size\_t \_\_pos, int \_\_val) noexcept\
 constexpr **bitset**\< \_Nb \> & **std::bitset\< \_Nb \>::\_Unchecked\_reset** (size\_t \_\_pos) noexcept\
 constexpr **bitset**\< \_Nb \> & **std::bitset\< \_Nb \>::\_Unchecked\_flip** (size\_t \_\_pos) noexcept\
 constexpr bool **std::bitset\< \_Nb \>::\_Unchecked\_test** (size\_t \_\_pos) const noexcept\

## Detailed Description

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 arguments

- •

  constant\_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.

## Function Documentation

### template\<typename \_Tp\> const \_Tp & \_\_gnu\_cxx::\_\_median (const \_Tp & \_\_a, const \_Tp & \_\_b, const \_Tp & \_\_c)

Find the median of three values.

**Parameters**

*\_\_a* A value. \
 *\_\_b* A value. \
 *\_\_c* A value.

**Returns**

One of 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.

### template\<typename \_Tp, typename \_Compare\> 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.

**Parameters**

*\_\_a* A value. \
 *\_\_b* A value. \
 *\_\_c* A value. \
 *\_\_comp* A binary predicate.

**Returns**

One of 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.

### template\<size\_t \_Nb\> size\_t std::bitset\< \_Nb \>::\_Find\_first () const \[inline\], \[constexpr\], \[noexcept\]

Finds the index of the first "on" bit.

**Returns**

The index of the first bit set, or size() if not found.

**See also**

\_Find\_next

### template\<size\_t \_Nb\> size\_t std::bitset\< \_Nb \>::\_Find\_next (size\_t \_\_prev) const \[inline\], \[constexpr\], \[noexcept\]

Finds the index of the next "on" bit after prev.

**Returns**

The index of the next bit set, or size() if not found.

**Parameters**

*\_\_prev* Where to start searching.

**See also**

\_Find\_first

### template\<size\_t \_Nb\> bitset\< \_Nb \> & std::bitset\< \_Nb \>::\_Unchecked\_flip (size\_t \_\_pos) \[inline\], \[constexpr\], \[noexcept\]

These versions of single-bit set, reset, flip, and test are extensions from the SGI version. They do no range checking.

Referenced by **flip()**.

### template\<size\_t \_Nb\> bitset\< \_Nb \> & std::bitset\< \_Nb \>::\_Unchecked\_reset (size\_t \_\_pos) \[inline\], \[constexpr\], \[noexcept\]

These versions of single-bit set, reset, flip, and test are extensions from the SGI version. They do no range checking.

Referenced by **reset()**.

### template\<size\_t \_Nb\> bitset\< \_Nb \> & std::bitset\< \_Nb \>::\_Unchecked\_set (size\_t \_\_pos) \[inline\], \[constexpr\], \[noexcept\]

These versions of single-bit set, reset, flip, and test are extensions from the SGI version. They do no range checking.

Referenced by **set()**.

### template\<size\_t \_Nb\> bitset\< \_Nb \> & std::bitset\< \_Nb \>::\_Unchecked\_set (size\_t \_\_pos, int \_\_val) \[inline\], \[constexpr\], \[noexcept\]

These versions of single-bit set, reset, flip, and test are extensions from the SGI version. They do no range checking.

### template\<size\_t \_Nb\> bool std::bitset\< \_Nb \>::\_Unchecked\_test (size\_t \_\_pos) const \[inline\], \[constexpr\], \[noexcept\]

These versions of single-bit set, reset, flip, and test are extensions from the SGI version. They do no range checking.

Referenced by **operator\[\]()**, and **test()**.

### template\<class \_Operation1, class \_Operation2\> unary\_compose\< \_Operation1, \_Operation2 \> \_\_gnu\_cxx::compose1 (const \_Operation1 & \_\_fn1, const \_Operation2 & \_\_fn2) \[inline\]

An **SGI extension** .

### template\<class \_Operation1, class \_Operation2, class \_Operation3\> binary\_compose\< \_Operation1, \_Operation2, \_Operation3 \> \_\_gnu\_cxx::compose2 (const \_Operation1 & \_\_fn1, const \_Operation2 & \_\_fn2, const \_Operation3 & \_\_fn3) \[inline\]

An **SGI extension** .

### template\<class \_Result\> constant\_void\_fun\< \_Result \> \_\_gnu\_cxx::constant0 (const \_Result & \_\_val) \[inline\]

An **SGI extension** .

### template\<class \_Result\> constant\_unary\_fun\< \_Result, \_Result \> \_\_gnu\_cxx::constant1 (const \_Result & \_\_val) \[inline\]

An **SGI extension** .

### template\<class \_Result\> constant\_binary\_fun\< \_Result, \_Result, \_Result \> \_\_gnu\_cxx::constant2 (const \_Result & \_\_val) \[inline\]

An **SGI extension** .

### template\<typename \_InputIterator, typename \_Size, typename \_OutputIterator\> std::pair\< \_InputIterator, \_OutputIterator \> \_\_gnu\_cxx::copy\_n (\_InputIterator \_\_first, \_Size \_\_count, \_OutputIterator \_\_result) \[inline\]

Copies the range \[first,first+count) into \[result,result+count).

**Parameters**

*\_\_first* An input iterator. \
 *\_\_count* The number of elements to copy. \
 *\_\_result* An output iterator.

**Returns**

A std::pair composed of first+count and result+count.

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).

References **std::\_\_iterator\_category()**.

### template\<typename \_InputIterator, typename \_Distance\> void \_\_gnu\_cxx::distance (\_InputIterator \_\_first, \_InputIterator \_\_last, \_Distance & \_\_n) \[inline\]

This is an SGI extension.

**Todo**

Needs documentation! See http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation\_style.html

References **std::\_\_iterator\_category()**, and **distance()**.

Referenced by **\_\_gnu\_cxx::temporary\_buffer\< \_ForwardIterator, \_Tp \>::temporary\_buffer()**, and **distance()**.

### template\<class \_Tp\> \_Tp \_\_gnu\_cxx::identity\_element (std::multiplies\< \_Tp \> ) \[inline\]

An **SGI extension** .

### template\<class \_Tp\> \_Tp \_\_gnu\_cxx::identity\_element (std::plus\< \_Tp \> ) \[inline\]

An **SGI extension** .

### template\<typename \_InputIterator1, typename \_InputIterator2\> int \_\_gnu\_cxx::lexicographical\_compare\_3way (\_InputIterator1 \_\_first1, \_InputIterator1 \_\_last1, \_InputIterator2 \_\_first2, \_InputIterator2 \_\_last2)

memcmp on steroids.

**Parameters**

*\_\_first1* An input iterator. \
 *\_\_last1* An input iterator. \
 *\_\_first2* An input iterator. \
 *\_\_last2* An input iterator.

**Returns**

An int, as with 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.

### template\<typename \_Tp, typename \_Integer\> \_Tp \_\_gnu\_cxx::power (\_Tp \_\_x, \_Integer \_\_n) \[inline\]

This is an SGI extension.

**Todo**

Needs documentation! See http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation\_style.html

### template\<typename \_Tp, typename \_Integer, typename \_MonoidOperation\> \_Tp \_\_gnu\_cxx::power (\_Tp \_\_x, \_Integer \_\_n, \_MonoidOperation \_\_monoid\_op) \[inline\]

This is an SGI extension.

**Todo**

Needs documentation! See http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation\_style.html

### template\<typename \_InputIterator, typename \_RandomAccessIterator\> \_RandomAccessIterator \_\_gnu\_cxx::random\_sample (\_InputIterator \_\_first, \_InputIterator \_\_last, \_RandomAccessIterator \_\_out\_first, \_RandomAccessIterator \_\_out\_last) \[inline\]

This is an SGI extension.

**Todo**

Needs documentation! See http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation\_style.html

### template\<typename \_InputIterator, typename \_RandomAccessIterator, typename \_RandomNumberGenerator\> \_RandomAccessIterator \_\_gnu\_cxx::random\_sample (\_InputIterator \_\_first, \_InputIterator \_\_last, \_RandomAccessIterator \_\_out\_first, \_RandomAccessIterator \_\_out\_last, \_RandomNumberGenerator & \_\_rand) \[inline\]

This is an SGI extension.

**Todo**

Needs documentation! See http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation\_style.html

### template\<typename \_ForwardIterator, typename \_OutputIterator, typename \_Distance\> \_OutputIterator \_\_gnu\_cxx::random\_sample\_n (\_ForwardIterator \_\_first, \_ForwardIterator \_\_last, \_OutputIterator \_\_out, const \_Distance \_\_n)

This is an SGI extension.

**Todo**

Needs documentation! See http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation\_style.html

References **std::distance()**, **std::min()**, and **random\_sample\_n()**.

Referenced by **random\_sample\_n()**.

### template\<typename \_ForwardIterator, typename \_OutputIterator, typename \_Distance, typename \_RandomNumberGenerator\> \_OutputIterator \_\_gnu\_cxx::random\_sample\_n (\_ForwardIterator \_\_first, \_ForwardIterator \_\_last, \_OutputIterator \_\_out, const \_Distance \_\_n, \_RandomNumberGenerator & \_\_rand)

This is an SGI extension.

**Todo**

Needs documentation! See http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation\_style.html

References **std::distance()**, and **std::min()**.

### template\<typename \_InputIter, typename \_Size, typename \_ForwardIter\> std::pair\< \_InputIter, \_ForwardIter \> \_\_gnu\_cxx::uninitialized\_copy\_n (\_InputIter \_\_first, \_Size \_\_count, \_ForwardIter \_\_result) \[inline\]

Copies the range \[first,last) into result.

**Parameters**

*\_\_first* An input iterator. \
 *\_\_count* Length \
 *\_\_result* An output iterator.

**Returns**

\_\_result + (\_\_first + \_\_count)

Like copy(), but does not require an initialized output range.

References **std::\_\_iterator\_category()**.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
