增强uuid +增强字节序

编程入门 行业动态 更新时间:2024-10-26 02:31:13
本文介绍了增强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 +增强字节序

本文发布于:2023-11-10 01:15:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573956.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字节   uuid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!