boost::interprocess::string 转换为 char*
是否可以将 boost::interprocess::string
转换为 std::string
或 const char*
?类似 c_str()
...
例如:
boost::interprocess::string is = "Hello world";
const char* ps = is.c_str(); // something similar
printf("%s", ps);
我什至可以在非共享内存块中获取字符串的副本。
例如:
boost::interprocess::string is = "Hello world";
const char cs[100];
strcpy(cs, is.c_str()); // something similar
printf("%s", cs);
谢谢!
Is it possible to convert a boost::interprocess::string
to an std::string
or to a const char*
? Something like c_str()
...
E.g.:
boost::interprocess::string is = "Hello world";
const char* ps = is.c_str(); // something similar
printf("%s", ps);
I could even get a copy of the string in a non-shared memory block.
E.g.:
boost::interprocess::string is = "Hello world";
const char cs[100];
strcpy(cs, is.c_str()); // something similar
printf("%s", cs);
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
boost::interprocess::string 有一个标准的 c_str() 方法。我在此处找到了以下内容:
(这是针对
basic_string
的。string
是一个模板实例化,其中CharT
模板参数是char
。) ,文档此处 说
boost::interprocess::string has a standard c_str() method. I found the following here:
(That's for the
basic_string
.string
is a template instantiation in which theCharT
template parameter ischar
.)Also, the documentation here says