【发布时间】:2018-12-20 00:41:41
【问题描述】:
我正在尝试以这种方式从boost::compute::detail::sha1 生成boost::uuids::uuid:
#include <iostream>
#include "boost/uuid/uuid.hpp"
#include "boost/uuid/uuid_io.hpp"
#include "boost/uuid/string_generator.hpp"
#include "boost/compute/detail/sha1.hpp"
int main(int argc, char* argv[])
{
try
{
boost::compute::detail::sha1 sha1("b888e35f9edf3794760392e1066d69-f43d-452e-8475-a09bae9a2e8500000000-0000-0000-0000-000000000000");
std::string str = sha1;
boost::uuids::uuid uuid = boost::uuids::string_generator()(str); // ERROR HERE!!
}
catch (std::exception& e)
{
std::cerr << "Error occurred: " << e.what() << std::endl;
}
return 0;
}
但此代码失败并出现错误Error occurred: invalid uuid string(见上文)
我正在使用 Visual Studio 2017,Boost 1.67
我的错误在哪里?如何从 boost::compute::detail::sha1 生成 boost::uuids::uuid
PS:该代码适用于以前的 boost 版本。
【问题讨论】:
-
使用
detail命名空间中的任何东西都是一种注定失败的方法... -
你知道更好的方法吗? :)
-
也许,如果我知道你想要完成什么。 ;-] SHA1 是 160 位,UUID 是 128 位——哪些数据被丢弃了,当您大概只需要从输入中删除 32 位时,为什么要涉及 Boost.Compute?
-
@ildjarn 我正在尝试根据此字符串生成唯一的 uuid
"b888e35f9edf3794760392e1066d69-f43d-452e-8475-a09bae9a2e8500000000-0000-0000-0000-000000000000"
标签: c++ boost sha1 boost-uuid boost-compute