是std :: streampos保证无符号long long? [英] Is std::streampos guaranteed to be unsigned long long?
问题描述
std :: streampos
保证是 unsigned long long
? 如果不是这样, std :: istream :: seekg
如何在大于4G的文件上正常工作?
从 http:// en .cppreference.com / w / cpp / io / fpos :
std :: streampos
是类模板的专门化
template< / p> class State> class fpos;
std :: streampos
is typedef'ed每个类型的对象都是 std :: fpos
)的私有成员。
从 http:// en .cppreference.com / w / cpp / io / streamoff :
long long
。
回答您的问题...
问题是 回答我相信你的意思是要找出是否保持位置的基本整数类型是保证 问题如果不是这样, 回答一个操作系统支持使用大于4G的文件,相应的是 std :: streamoff值-1也用于表示一些I / O库函数。 Is If not so, how does From http://en.cppreference.com/w/cpp/io/fpos: Each object of type From http://en.cppreference.com/w/cpp/io/streamoff: The type To answer your questions... Question Is Answer I am sure you meant to find out whether the underlying integral type that holds the position is guaranteed to be Question If not so, how does Answer If an operating system supports working with files larger than 4G, it's A std::streamoff value of -1 is also used to represent error conditions by some of the I/O library functions.
这篇关于是std :: streampos保证无符号long long?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! std :: streampos
保证是 unsigned long long
unsigned long long
。从这个意义上说,真正的问题是,是否将 std :: streamoff
保存为无符号long long
。这个问题的答案是否,正如你从上面的描述中推断出的那样。
std :: istream :: seekg
在大于4G的文件上正常工作?
std :: streamoff
。即使如此,这很可能是一个有符号整数类型。以下是 http://en.cppreference.com/w/cpp/io/streamoff 。
$ b
std::streampos
guaranteed to be unsigned long long
?std::istream::seekg
work correctly on files larger than 4G?std::streampos
is a specialization of the class templatetemplate< class State > class fpos;
std::streampos
is typedef'ed to be std::fpos<std::char_traits<char>::state_type>
fpos
holds the byte position in the stream (typically as a private member of type std::streamoff
). std::streamoff
is a signed integral type of sufficient size to represent the maximum possible file size supported by the operating system. Typically, this is a typedef to long long
.std::streampos
guaranteed to be unsigned long long
?unsigned long long
. In that sense, the real question is whether std::streamoff
is gueranteed to be unsigned long long
. The answer to that question is "No", as you can infer from the descriptions above.std::istream::seekg
work correctly on files larger than 4G?std::streamoff
is typdef'ed accordingly. Even then, it is most likely going to be a signed integral type. Here's another quote from http://en.cppreference.com/w/cpp/io/streamoff.