我需要将uuid放置在我无法控制的内存中的位置(将指针传递给我(由文件进行shm支持)),但是我必须确保在给定指针处存储的内容将是可移植的,即我想使用boost :: endian来为uuid设置little endian.可以结合使用boost :: endian和boost:uuid吗?
I need to place uuids at locations in memory that I don't control (a pointer is passed to me (to shm backed by file)), but I have to make sure that what I store at the given pointers will be portable, i.e. I would like to use boost::endian to settle on little endian for the uuids. Is it possible to combine boost::endian and boost:uuid for that?
推荐答案您无需担心UUID的字节序.它们不被视为数值.它们只是16个字节的不透明块.您可以对UUID执行的唯一有意义的操作是比较是否相等.
You don't need to worry about endianness with UUIDs. They are not treated as numeric values. They are simply opaque blocks of 16 bytes. The only meaningful operation you can perform on UUIDs is comparison for equality.
更新:在某些情况下,字节序可能很重要.例如如果要在多个平台上将UUID转换为字符串表示形式,并且需要所有这些字符串表示形式进行匹配.
Update: In some cases endianness may matter. e.g. if you are converting the UUID to a string representation on multiple platforms and you need all those string representations to match.
更多推荐
增强uuid +增强字节序
发布评论