简体   繁体   English

c ++ boost :: multi_array索引太大了

[英]c++ boost::multi_array index too large

I'm using a two-dimensional boost::multi_array to store objects of a custom struct. 我正在使用二维boost :: multi_array来存储自定义结构的对象。 The problem is that I have a huge amount of these objects so that the index of the array I would need exceeds the range of an integer. 问题是我有大量的这些对象,因此我需要的数组索引超出了整数的范围。 Is there any possibility to use long as an index of a multi-array or do you have any other suggestions on how to store a dataset this big and still keep it accessible at a decent speed? 是否有可能使用long作为多数组的索引,或者您是否有任何其他建议如何存储这么大的数据集并仍以合适的速度保持可访问性?

Thanks! 谢谢!

The official documentation states that the index type is unspecified , but looking into the repository , one sees that the definition most likely is typedef std::ptrdiff_t index ; 官方文档指出索引类型未指定 ,但是查看存储库 ,可以看到定义最有可能是typedef std::ptrdiff_t index ;

So if you compile for an x86 32-bit system, you will surely run out of addressable memory anyways, so the limited size of indicies is not your real problem. 因此,如果你编译一个x86 32位系统,你肯定会耗尽可寻址的内存,所以有限的标记大小不是你真正的问题。 Your only option would be to chose a system with enough memory, which has to be one with more than 2^32 bytes and thus has to be a 64 bit one. 您唯一的选择是选择一个具有足够内存的系统,该系统必须是一个超过2 ^ 32字节的系统,因此必须是64位。 2^64 will be certainly enough to represent the dimensions of your multiarray. 2 ^ 64肯定足以代表多阵列的尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM