Namespaces
Variants

std::basic_streambuf<CharT,Traits>:: pubseekoff, std::basic_streambuf<CharT,Traits>:: seekoff

From cppreference.net
pos_type pubseekoff ( off_type off, std:: ios_base :: seekdir dir,
std:: ios_base :: openmode which = ios_base :: in | ios_base :: out ) ;
(1)
protected :

virtual pos_type seekoff ( off_type off, std:: ios_base :: seekdir dir,

std:: ios_base :: openmode which = ios_base :: in | ios_base :: out ) ;
(2)

设置输入和/或输出序列的位置指示器相对于其他某个位置的位置。

1) 调用最派生类的 seekoff ( off, dir, which )
2) 此函数的基类版本无实际作用。派生类可重写此函数以实现位置指示器的相对定位。

目录

参数

off - 设置位置指示器的相对偏移量
dir - 定义应用相对偏移的基准位置。可以是以下常量之一:
常量 说明
beg 流的起始位置
end 流的结束位置
cur 流位置指示器的当前位置
which - 定义要影响的输入和/或输出序列。可以是以下常量之一或其组合:
常量 说明
in 影响输入序列
out 影响输出序列

注释

并非所有参数组合都有效,详情请参阅 seekoff 的派生版本。

返回值

1) seekoff ( off, dir, which ) 的返回值
2) 由位置指示器定义的最终绝对位置。基类版本返回 pos_type ( off_type ( - 1 ) )

示例

缺陷报告

以下行为变更缺陷报告被追溯应用于先前发布的C++标准。

缺陷报告 适用标准 发布行为 正确行为
LWG 55 C++98 基类版本的 seekoff 返回
未定义的无效流位置
返回 pos_type ( off_type ( - 1 ) )

参见

调用 seekpos ( )
(公开成员函数)
[virtual]
使用相对寻址重定位文件位置
std::basic_filebuf<CharT,Traits> 的虚受保护成员函数)
[virtual]
使用相对寻址重定位输入序列、输出序列或两者的下一个指针
std::basic_stringbuf<CharT,Traits,Allocator> 的虚受保护成员函数)
[virtual]
使用相对寻址重定位输入序列、输出序列或两者的下一个指针
std::strstreambuf 的虚受保护成员函数)