[fpos.operations]

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

## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#fpos.operations)

### 31.5.3 Class template fpos [[fpos]](fpos#operations)

#### 31.5.3.3 Requirements [fpos.operations]

[1](#1)

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

An fpos type specifies file position information[.](#1.sentence-1)

It holds a state object
whose type is equal to the template parameter stateT[.](#1.sentence-2)

Type stateT shall meet
the [*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [30](utility.arg.requirements#tab:cpp17.defaultconstructible "Table 30: Cpp17DefaultConstructible requirements")),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [32](utility.arg.requirements#tab:cpp17.copyconstructible "Table 32: Cpp17CopyConstructible requirements (in addition to Cpp17MoveConstructible)")),[*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [34](utility.arg.requirements#tab:cpp17.copyassignable "Table 34: Cpp17CopyAssignable requirements (in addition to Cpp17MoveAssignable)")), and[*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [35](utility.arg.requirements#tab:cpp17.destructible "Table 35: Cpp17Destructible requirements")) requirements[.](#1.sentence-3)

If is_trivially_copy_constructible_v<stateT> is true,
then fpos<stateT> has a trivial copy constructor[.](#1.sentence-4)

If is_trivially_copy_assignable_v<stateT> is true,
then fpos<stateT> has a trivial copy assignment operator[.](#1.sentence-5)

If is_trivially_destructible_v<stateT> is true,
then fpos<stateT> has a trivial destructor[.](#1.sentence-6)

All specializations of fpos meet
the [*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"),[*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]"),[*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"),
and [*Cpp17EqualityComparable*](utility.arg.requirements#:Cpp17EqualityComparable "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [28](utility.arg.requirements#tab:cpp17.equalitycomparable "Table 28: Cpp17EqualityComparable requirements")) requirements[.](#1.sentence-7)

In addition, the expressions shown in Table [141](#tab:fpos.operations "Table 141: Position type requirements") are valid and have the indicated semantics[.](#1.sentence-8)

In that table,

- [(1.1)](#1.1)

P refers to a specialization of fpos,

- [(1.2)](#1.2)

p and q refer to values
of type P or const P,

- [(1.3)](#1.3)

pl and ql refer to modifiable lvalues of type P,

- [(1.4)](#1.4)

O refers to type streamoff, and

- [(1.5)](#1.5)

o and o2 refer to values
of type streamoff or const streamoff[.](#1.sentence-9)

Table [141](#tab:fpos.operations) — Position type requirements [[tab:fpos.operations]](./tab:fpos.operations)  

| [ð](#tab:fpos.operations-row-1)<br>**Expression** | **Return type** | **Operational** | **Assertion/note** |
| --- | --- | --- | --- |
| [ð](#tab:fpos.operations-row-2) |  | **semantics** | **pre-/post-condition** |
| [ð](#tab:fpos.operations-row-3)<br>P(o) | P | converts from offset | *Effects*: Value-initializes the state object[.](#tab:fpos.operations-row-3-column-4-sentence-1) |
| [ð](#tab:fpos.operations-row-4)<br>P p(o);   P p = o; |  |  | *Effects*: Value-initializes the state object[.](#tab:fpos.operations-row-4-column-4-sentence-1)<br>   *Postconditions*: p == P(o) is true[.](#tab:fpos.operations-row-4-column-4-sentence-2) |
| [ð](#tab:fpos.operations-row-5)<br>P() | P | P(0) |  |
| [ð](#tab:fpos.operations-row-6)<br>P p; |  | P p(0); |  |
| [ð](#tab:fpos.operations-row-7)<br>O(p) | streamoff | converts to offset | P(O(p)) == p |
| [ð](#tab:fpos.operations-row-8)<br>p == q | bool |  | *Remarks*: For any two values o and o2,  if p is obtained  from o converted to P or  from a copy of such P value and  if q is obtained  from o2 converted to P or  from a copy of such P value,  then p == q is true  only if o == o2 is true[.](#tab:fpos.operations-row-8-column-4-sentence-1) |
| [ð](#tab:fpos.operations-row-9)<br>p != q | bool | !(p == q) |  |
| [ð](#tab:fpos.operations-row-10)<br>p + o | P | + offset | *Remarks*: With ql = p + o;, then: ql - o == p |
| [ð](#tab:fpos.operations-row-11)<br>pl += o | P& | += offset | *Remarks*: With ql = pl; before the +=, then:  pl - o == ql |
| [ð](#tab:fpos.operations-row-12)<br>p - o | P | - offset | *Remarks*: With ql = p - o;, then: ql + o == p |
| [ð](#tab:fpos.operations-row-13)<br>pl -= o | P& | -= offset | *Remarks*: With ql = pl; before the -=, then:  pl + o == ql |
| [ð](#tab:fpos.operations-row-14)<br>o + p | convertible to P | p + o | P(o + p) == p + o |
| [ð](#tab:fpos.operations-row-15)<br>p - q | streamoff | distance | p == q + (p - q) |

[2](#2)

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

Stream operations that return a value of typetraits​::​pos_type returnP(O(-1)) as an invalid value to signal an error[.](#2.sentence-1)

If this value is used as an argument to anyistream,ostream,
orstreambuf member
that accepts a value of typetraits​::​pos_type then the behavior of that function is undefined[.](#2.sentence-2)
