'R'字符串文本的上下文中是什么意思?
What does 'R' mean in the context of string literals?
这段代码基本上与 AMPS 服务器通信并尝试发布主题。
publish(
(的第二个参数中R
的含义是什么?
#include <ampsplusplus.hpp>
#include <iostream>
int main(void)
{
const char* uri = "tcp://127.0.0.1:9007/amps/json";
// Construct a client with the name "examplePublisher".
AMPS::Client ampsClient("examplePublisher");
try
{
// connect to the server and log on
ampsClient.connect(uri);
ampsClient.logon();
// publish a JSON message
ampsClient.publish("messages",
R"({ "message" : "Hello, World!" ,)"
R"(client" : 1 })");
}
catch (const AMPS::AMPSException& e)
{
std::cerr << e.what() << std::endl;
exit(1);
}
return 0;
}
前缀(可选(
R "delimiter( raw_characters )delimiter"
(6( (自 C++11 起(
原始字符串文本。用于避免转义任何字符。分隔符之间的任何内容都将成为字符串的一部分。前缀(如果存在(与上述含义相同。
例:
const char* s1 = R"foo(
Hello
World
)foo";
//same as
const char* s2 = "nHellonWorldn";
其中foo
是分隔符。
在您的情况下,message
将打印:
{ "message" : "Hello, World!" ,client" : 1 }
相关文章:
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- 标准 N3337 5.2.10 第 7 条中的C++"类型"是什么意思?
- "类模板示例<int>;"语句对 C++11 是什么意思?
- 线应该是什么意思
- "CID"在AT+HTTPPARA= "CID" ,1中是什么意思
- 表达式"b=(b-x)&x"是什么意思?
- 这个表达是什么意思?
- 此代码验证公式是什么意思?
- 跟踪日志中的T.11803()是什么意思?
- 这个额外的关键字在这个 c++ 类声明中是什么意思?
- * 和 ** 在 C++ 函数声明中是什么意思?
- _T("xyz")是什么意思?
- #define Dbg(fmt,..) (0) 是什么意思? 警告:表达式无效
- 这行代码到底是什么意思?
- 在命名空间名称之前加上 :: 是什么意思?
- 从字符数组的元素中减去'a'是什么意思
- "friend"关键字在C++中是什么意思?
- 减法中的"0"是什么意思?
- 字符数组前面的加号是什么意思?
- 这里的字符串函数是什么意思