stout代码分析之五:UUID类

时间:2016-09-19 23:57:38   收藏:0   阅读:417

  UUID全称通用唯一识别码,被广泛应用于分布式系统中,让所有的元素具有唯一的标识。

  stout中UUID类继承自boost::uuids::uuid。api如下:

  废话不多说,上示例代码:

#include "stout/uuid.hpp"
#include <iostream>
int main()
{
  UUID a = UUID::random();
  UUID b = UUID::fromBytes(a.toBytes());
  UUID c = UUID::fromString(a.toString());
  std::cout << a.toString()
    << "," << b.toString()
    << "," << c.toString() << std::endl;
  return 0;
}

 

原文:http://www.cnblogs.com/taiyang-li/p/5887064.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!