gpt4 book ai didi

c++ - spdlog error : "don' t know how to format the type, include fmt/ostream.h 如果它提供了应该使用的运算符<<”

转载 作者:搜寻专家 更新时间:2023-10-31 01:27:23 38 4
gpt4 key购买 nike

我刚刚开始使用 spdlog 来改进我们的日志记录。我们的日志记录非常基础,所以我只是几乎逐字复制“多接收器”示例以记录到文件和控制台。

但是,即使完全按照示例进行操作,我也会得到:

错误 C2338 不知道如何格式化类型,包括 fmt/ostream.h 如果它提供了应该使用的运算符<< Logger d:\tfs\development\bladed\main\external\spdlog\spdlog- 1.x\include\spdlog\fmt\bundled\core.h 351

来自core.h:

// A formatter for objects of type T.
template <typename T, typename Char = char, typename Enable = void>
struct formatter {
static_assert(no_formatter_error<T>::value,
"don't know how to format the type, include fmt/ostream.h if it provides "
"an operator<< that should be used");

我假设这很容易修复,但我看不到...

[基本的 Win32 用法]

最佳答案

@PaulMcKenzie 给我指出了正确的方向,看来我正在尝试记录一种 spdlog 默认无法处理的字符串类型 (std::wstrings)。

Visual Studio 的 Intellisense 似乎对模板感到困惑,让它似乎对我发送 spdlog::warn a std::wstring 很满意。

解决方案:要么只使用 std::string,要么如果您想使用 wstrings,您(可能)需要为它们定义一个自定义格式化程序。

关于c++ - spdlog error : "don' t know how to format the type, include fmt/ostream.h 如果它提供了应该使用的运算符<<”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53432887/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com