[fpos] (original) (raw)

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 stateT> class fpos { public: stateT state() const;void state(stateT);private: stateT st; };}

31.5.3.2 Members [fpos.members]

Effects: Assigns s to st.

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.

If is_trivially_copy_constructible_v<stateT> is true, then fpos<stateT> has a trivial copy constructor.

If is_trivially_copy_assignable_v<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.

In addition, the expressions shown in Table 139are valid and have the indicated semantics.

In that table,

Table 139 β€” 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_typereturnP(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_typethen the behavior of that function is undefined.