Files
2025-10-25 03:02:53 +03:00

7.0 KiB
Raw Permalink Blame History

[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);

1

#

Effects: Assigns s to st.

🔗

stateT state() const;

2

#

Returns: Current value of st.

31.5.3.3 Requirements [fpos.operations]

1

#

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)

2

#

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.