增强uuid +增强字节序 [英] Boost uuid + boost endian

查看:138
本文介绍了增强uuid +增强字节序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将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 +增强字节序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆