我做的二进制文件处理,并在我的算法,我想知道实际类型pos_type
和off_type
计算文件的大小或寻求一个给定的位置(例如当tellg
和seekg
).
当计算文件的我只是大小static_cast
的pos_type
一个int64_t
,它似乎很好地工作.
怎么样seekg
?传递int64_t
给它是否安全?
有没有办法制作 pos_type
和 off_type
成为 int64_t
,也许使用 traits
?
我想消除这个可怕的演员并找到一种符合C++标准的方法.
更新:另见
Cri*_*dam 10
并非所有编译器都具有大文件支持的STL实现.
例如,以下程序:
#include <fstream>
#include <iostream>
#include <limits>
int main()
{
using namespace std;
cout << numeric_limits<streamoff>::max() << endl;
}
Run Code Online (Sandbox Code Playgroud)
结果是:
另一方面,STLPort具有跨平台大文件支持.
归档时间: |
|
查看次数: |
2622 次 |
最近记录: |