[ios.base.callback]

# 31 Input/output library [[input.output]](./#input.output)

## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.base.callback)

### 31.5.2 Class ios_base [[ios.base]](ios.base#callback)

#### 31.5.2.7 Callbacks [ios.base.callback]

[ð](#lib:register_callback,ios_base)

`void register_callback(event_callback fn, int idx);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1565)

*Preconditions*: The functionfn does not throw exceptions[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1571)

*Effects*: Registers the pair(fn, idx) such that during calls toimbue() ([[ios.base.locales]](ios.base.locales "31.5.2.4 Functions")),copyfmt(),
or~ios_base() ([[ios.base.cons]](ios.base.cons "31.5.2.8 Constructors and destructor")),
the functionfn is called with argumentidx[.](#2.sentence-1)

Functions registered are called when an event occurs, in opposite order of
registration[.](#2.sentence-2)

Functions registered while a callback function is active are not called until the next event[.](#2.sentence-3)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1588)

*Remarks*: Identical pairs are not merged[.](#3.sentence-1)

A function registered twice will be called twice[.](#3.sentence-2)
