An
fpos type specifies file position information
. It holds a state object
whose type is equal to the template parameter
stateT. Type
stateT shall meet
the
Cpp17DefaultConstructible (Table
24),
Cpp17CopyConstructible (Table
26),
Cpp17CopyAssignable (Table
28), and
Cpp17Destructible (Table
29) requirements
. If
is_trivially_copy_constructible_v<stateT> is
true,
then
fpos<stateT> has a trivial copy constructor
. If
is_trivially_copy_assignable<stateT> is
true,
then
fpos<stateT> has a trivial copy assignment operator
. If
is_trivially_destructible_v<stateT> is
true,
then
fpos<stateT> has a trivial destructor
. All specializations of
fpos satisfy
the
Cpp17DefaultConstructible,
Cpp17CopyConstructible,
Cpp17CopyAssignable,
Cpp17Destructible,
and
Cpp17EqualityComparable (Table
22) requirements
. In addition, the expressions shown in Table
110
are valid and have the indicated semantics
. In that table,
P refers to an instance of fpos,
p and q refer to values
of type P or const P,
pl and ql refer to modifiable lvalues of type P,
O refers to type streamoff, and
o refers to a value
of type
streamoff or
const streamoff.
Table
110 — Position type requirements
Expression | Return type | Operational | Assertion/note |
| | semantics | pre-/post-condition |
P(o) | P | converts from offset | Effects: Value-initializes the state object . |
P p(o);
P p = o; | | | Effects: Value-initializes the state object .
Ensures: p == P(o)
|
P() | P | P(0) | |
P p; | | P p(0); | |
O(p) | streamoff | converts to offset | P(O(p)) == p |
p != q | convertible to bool | !(p == q) | |
p + o | P | + offset | Remarks: With ql = p + o;, then: ql - o == p |
pl += o | P& | += offset | Remarks: With ql = pl; before the +=, then:
pl - o == ql |
p - o | P | - offset | Remarks: With ql = p - o;, then: ql + o == p |
pl -= o | P& | -= offset | Remarks: With ql = pl; before the -=, then:
pl + o == ql |
o + p | convertible to P | p + o | P(o + p) == p + o |
p - q | streamoff | distance | p == q + (p - q) |
Stream operations that return a value of type
traits::pos_type
return
P(O(-1))
as an invalid value to signal an error
. If this value is used as an argument to any
istream,
ostream,
or
streambuf member
that accepts a value of type
traits::pos_type
then the behavior of that function is undefined
.