Visual Studio中的C ++ 20支持 [英] C++20 support in Visual Studio

查看:290
本文介绍了Visual Studio中的C ++ 20支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 std :: format ,但是Visual Studio说 std 命名空间没有成员 format

I'm wanting to use std::format but Visual Studio says the std namespace has no member format.

看来这是C ++ 20的新功能。有没有办法使它可用?

It appears this is new for C++20. Is there a way to make it available?

推荐答案

截至撰写本文时,没有C ++标准库实现 std :: format

As of the time of writing, no C++ standard library implements std::format.

网络上有多种实现方式,例如 https://github.com/fmtlib/fmt (可能是提案的原始来源,位于 fmt :: )和 https://github.com/mknejp/std-format (这会将所有内容放入 std :: experimental :: )。

There are various implementations available on the web, like https://github.com/fmtlib/fmt (presumably the original source of the proposal, in fmt::) and https://github.com/mknejp/std-format (which puts everything in std::experimental::).

我不建议将它们放入 std 。如果我必须处理类似的事情,我将寻求的解决方案是:

I wouldn't recommend pulling these into std. If I had to deal with something like this, the solution I would go for would be:


  • 添加 #define<某些唯一名称> _format< whereevergt; :: format ,然后使用<某些唯一名称> _format

然后,一旦获得 std :: format 支持,就可以进行搜索和替换<某些唯一名称> _format std :: format 并抛弃#定义

Then, once you get std::format support, search-and-replace <some-unique-name>_format with std::format and toss the #define.

它使用宏,但是从长远来看,这比不使用宏要好。 格式到处都是

It uses macros, but in the long run it's better than having unqualified format everywhere.

这篇关于Visual Studio中的C ++ 20支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆