7.0 KiB
[fpos]
31 Input/output library [input.output]
31.5 Iostreams base classes [iostreams.base]
31.5.3 Class template fpos [fpos]
31.5.3.1 General [fpos.general]
namespace std {template class fpos {public:// [fpos.members], members stateT state() const; void state(stateT); private: stateT st; // exposition only};}
31.5.3.2 Members [fpos.members]
void state(stateT s);
Effects: Assigns s to st.
stateT state() const;
Returns: Current value of st.
31.5.3.3 Requirements [fpos.operations]
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 30),Cpp17CopyConstructible (Table 32),Cpp17CopyAssignable (Table 34), andCpp17Destructible (Table 35) requirements.
If is_trivially_copy_constructible_v is true, then fpos has a trivial copy constructor.
If is_trivially_copy_assignable_v is true, then fpos has a trivial copy assignment operator.
If is_trivially_destructible_v is true, then fpos has a trivial destructor.
All specializations of fpos meet the Cpp17DefaultConstructible,Cpp17CopyConstructible,Cpp17CopyAssignable,Cpp17Destructible, and Cpp17EqualityComparable (Table 28) requirements.
In addition, the expressions shown in Table 141 are valid and have the indicated semantics.
In that table,
P refers to a specialization 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 and o2 refer to values of type streamoff or const streamoff.
Table 141 — Position type requirements [tab:fpos.operations]
| ð 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. Postconditions: p == P(o) is true. |
||
| ð P() |
P | P(0) | |
| ð P p; |
P p(0); | ||
| ð O(p) |
streamoff | converts to offset | P(O(p)) == p |
| ð 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. | |
| ð p != q |
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 typetraits::pos_type returnP(O(-1)) as an invalid value to signal an error.
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.