首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::fpos

Defined in header <ios>

?

?

template< class State > class fpos;

?

?

类模板的专门化std::fpos标识流或文件中的绝对位置。每个类型的对象fpos保持流%28中的字节位置,通常作为类型的私有成员std::streamoff%29和当前移位状态,类型为State%28典型std::mbstate_t29%。

的下列专门化std::fpos提供:

Type

Definition

streampos

std::fpos<std::char_traits<char>::state_type>

wstreampos

std::fpos<std::char_traits<wchar_t>::state_type>

In addition, std::u16streampos and std::u32streampos are provided as implementation-defined types that satisfy the requirements of pos_type.

(since C++11)

成员函数

state

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

此外,必须提供下列成员函数和运算符,但如果它们是成员或非会员,则必须提供未指定的%27s。

  • 接受类型参数的构造函数。int...
  • 接受类型参数的构造函数。std::streamoff此构造函数还必须接受特殊值。std::streamoff(-1)*std::fpos以这种方式构造的,由一些流操作返回,以指示错误。
  • 转换操作符,它可以转换fposstd::streamoff的值等于std::fpos(0)...
  • operator==,它比较了两个类型的对象。std::fpos并返回类型可转换为bool
  • operator!=,它比较了两个类型的对象。std::fpos并返回类型可转换为bool
  • operator+operator+=可以添加std::streamoffstd::fpos
  • operator-operator-=可以减去std::streamoffstd::fpos
  • operator-可以减去两个类型的对象std::fposstd::streamoff

注记

std::streamposstd::wstreampos必须是同一类型,因为std::char_traits<char>::state_typestd::char_traits<wchar_t>::state_type都必须是std::mbstate_tC++98有一种自相矛盾的说法,即如果实现不支持窄方向的ioStreams中的移位编码,但支持宽定向流中的一个或多个移位编码,则它们可能有所不同,但在C++03中已经纠正了这一点。

一些I/O流成员函数返回和操作成员ty对联f的对象pos_type对于流,这些成员类型由模板参数提供。Traits,默认为std::char_traits,它定义了它们的pos_typeS将是专门化的...std::fposI/O流库的行为是在Traits::pos_type不是std::fpos<std::mbstate_t>百分之二十八std::streamposstd::wstreampos29%。

另见

streamoff

represents relative file/stream position (offset from fpos), sufficient to represent any file size (typedef)

tellp

returns the output position indicator (public member function of std::basic_ostream)

seekp

sets the output position indicator (public member function of std::basic_ostream)

fgetpos

gets the file position indicator (function)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com