c++ - 使用 boost::lexical_cast 将 UUID 转换为字符串时出现 Boost 编译错误

标签 c++ boost uuid lexical-cast boost-uuid

我有这段代码是基于 SO 中的几篇文章:

boost::uuids::uuid uuid = boost::uuids::random_generator()();
auto uuidString= boost::lexical_cast<std::string>(uuid);

但是当我编译这段代码时,我得到了这个错误:

Source type is neither std::ostream`able nor std::wostream`able     C:\Local\boost\boost\lexical_cast\detail\converter_lexical.hpp  

我该如何修复这个错误?

最佳答案

我猜你错过了包含:

Live On Coliru

#include <boost/lexical_cast.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/random_generator.hpp>

int main() {
    boost::uuids::uuid uuid = boost::uuids::random_generator()();
    auto uuidString = boost::lexical_cast<std::string>(uuid);
}

关于c++ - 使用 boost::lexical_cast 将 UUID 转换为字符串时出现 Boost 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29631039/

相关文章:

c++ - 带有第二个删除器的 shared_ptr 链/分支

ios - 如何在钥匙串(keychain) iOS 中保存 UUID?

c++ - 为什么 vector 被认为是 nothrow_move_constructible?

c++ - 改变类对象数量的 vector

linux - Boost 找不到本地安装的 icu

python - python uuid1 是否作为时间戳顺序?

gcc - perl 模块 UUID-0.05 在 ubuntu 12.04 中 make 失败

c++ - 如何使用类的模板参数作为链表的模板参数传递?

c++ - 使用 Qt 信号和槽从另一个类更改标签文本

c++ - 我如何在没有显式函数定义的情况下使用 boost::bind 在 boost::shared_ptr 中保留引用?