最近项目的需要,使用了C++来生成uuid。这里找到了githup上面的sole.hpp。具体使用方法。可以参考网站。
https://github.com/r-lyeh-archived/sole
那么下面,我们来看一下以v0的方式生成uuid。
sole::uuid u0 = sole::uuid0();
string stru0 = u0.str();
因为是在其他方面的应用,我们尽量将中间的横杠去掉。
stru0.erase(std::remove(stru0.begin(), stru0.end(), '-'), stru0.end());
//注意添加下面的头文件
#include<algorithm>