简体   繁体   English

C++20 ""_a= 在做什么?

[英]What is the C++20 ""_a= doing?

In std::format in C++20 :C++20 的 std::format 中

print("Hello, {name}! The answer is {number}. Goodbye, {name}.\n",
      "name"_a=name, "number"_a=number);

What is the ""_a= doing? ""_a=在做什么?

""_a is a user defined literal. ""_a是用户定义的文字。

In this context it would help you create the equivalent arg("name", value) by writing it as "name"_a = value .在这种情况下,它将帮助您创建等效的arg("name", value) ,方法是将其写为"name"_a = value

However the named arguments didn't make it into the standard so this is not part of the standrd lib.然而,命名的 arguments 没有成为标准,所以这不是标准库的一部分。 You could still write it if you really wanted to.如果你真的想写,你仍然可以写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM