Namespaces
Variants
Views
Actions

std::fpos

From cppreference.com
< cpp‎ | io
Revision as of 18:18, 2 November 2012 by P12bot (Talk | contribs)

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <ios>
</td>

<td></td> <td></td> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td class="t-dcl-nopad">
template< class State >
class fpos;
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

Specializations of the class template std::fpos identify absolute positions in a stream or in a file. Each object of type fpos holds the byte position in the stream (typically as a private member of type std::streamoff) and the current shift state, a value of type State (typically std::mbstate_t).

Four specializations of std::fpos are provided:

Defined in header <ios>
Type Definition
streampos std::fpos<std::char_traits<char>::state_type>
u16streampos std::fpos<std::char_traits<char16_t>::state_type>
u32streampos std::fpos<std::char_traits<char32_t>::state_type>
wstreampos std::fpos<std::char_traits<wchar_t>::state_type>

Member functions

gets/sets the value of the shift state
(public member function)

In addition, the following member functions and operators must be provided, although it's unspecified if they are members or non-member.

  • A constructor that accepts an argument of type int.
  • A constructor that accepts an argument of type std::streamoff. This constructor must also accept the special value std::streamoff(-1): the std::fpos constructed in this manner is returned by some stream operations to indicate errors.
  • A conversion operator that converts fpos to std::streamoff with the value equal to the offset from std::fpos(0).
  • operator== that compares two objects of type std::fpos and returns a value of type convertible to bool
  • operator!= that compares two objects of type std::fpos and returns a value of type convertible to bool
  • operator- and operator-= which can subtract std::streamoff from an std::fpos
  • operator- which can subtract two objects of type std::fpos producing an std::streamoff

See also

Template:cpp/io/basic ostream/dcl list tellpTemplate:cpp/io/basic ostream/dcl list seekpTemplate:cpp/io/c/dcl list fgetpos
represents relative file/stream position (offset from fpos), sufficient to represent any file size
(typedef)